-
Notifications
You must be signed in to change notification settings - Fork 389
Open
Description
Reproduce:
- Create simple Core Data model with two entities…
╭───────╮ ╭───────╮
│ Alpha │ │ Beta │
├───────┤ ├───────┤
│ betas │ <-->> │ alpha │
╰───────╯ ╰───────╯
…with betas being optional, while alpha being mandatory.
-
Set
Codegenof entities toManual/None. -
Generate source code via mogenerator:
mogenerator --model ${SRCROOT}/MogeneratorCrash/MogeneratorCrash.xcdatamodeld/MogeneratorCrash.xcdatamodel --human-dir ${SRCROOT}/MogeneratorCrash/Human --machine-dir ${SRCROOT}/MogeneratorCrash/Machine --swift
-
Add generated code files to project.
-
Create entities:
guard let appDelegate = NSApplication.shared().delegate as? AppDelegate else {
fatalError("Could not find AppDelegate")
}
appDelegate.persistentContainer.performBackgroundTask { context in
let alpha = Alpha(context: context)
let beta = Beta(context: context)
alpha.addBetasObject(beta)
}
- Run app.
Expected Behavior
Shouldn't crash.
Actual Behavior
Crashes:
2017-04-03 18:13:50.752753 MogeneratorCrash[28856:15552094] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An NSManagedObject of class 'Alpha' must have a valid NSEntityDescription.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff9aeefe7b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffafacfcad objc_exception_throw + 48
2 CoreData 0x00007fff9aa828c0 -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:] + 528
3 MogeneratorCrash 0x0000000100005b8c _TFC16MogeneratorCrash6_AlphacfT6entityCSo19NSEntityDescription10insertIntoGSqCSo22NSManagedObjectContext__S0_ + 76
4 MogeneratorCrash 0x00000001000017d7 _TFC16MogeneratorCrash5AlphacfT6entityCSo19NSEntityDescription10insertIntoGSqCSo22NSManagedObjectContext__S0_ + 71
5 MogeneratorCrash 0x0000000100001892 _TToFC16MogeneratorCrash5AlphacfT6entityCSo19NSEntityDescription10insertIntoGSqCSo22NSManagedObjectContext__S0_ + 66
6 CoreData 0x00007fff9aaf4031 -[NSManagedObject initWithContext:] + 721
7 MogeneratorCrash 0x0000000100003334 _TTOFCSo15NSManagedObjectcfT7contextCSo22NSManagedObjectContext_S_ + 36
8 MogeneratorCrash 0x0000000100002ca1 _TFCSo15NSManagedObjectCfT7contextCSo22NSManagedObjectContext_S_ + 65
9 MogeneratorCrash 0x0000000100002bd3 _TFFC16MogeneratorCrash14ViewController11viewDidLoadFT_T_U_FCSo22NSManagedObjectContextT_ + 51
10 MogeneratorCrash 0x0000000100002cec _TTRXFo_oCSo22NSManagedObjectContext__XFdCb_dS___ + 60
11 CoreData 0x00007fff9aba9144 __47-[NSPersistentContainer performBackgroundTask:]_block_invoke + 20
12 CoreData 0x00007fff9aab7fa5 developerSubmittedBlockToNSManagedObjectContextPerform + 165
13 libdispatch.dylib 0x00000001009f0f5c _dispatch_client_callout + 8
14 libdispatch.dylib 0x0000000100a08a59 _dispatch_queue_serial_drain + 205
15 libdispatch.dylib 0x00000001009fa489 _dispatch_queue_invoke + 1174
16 libdispatch.dylib 0x0000000100a01707 _dispatch_queue_override_invoke + 656
17 libdispatch.dylib 0x00000001009f31d7 _dispatch_root_queue_drain + 671
18 libdispatch.dylib 0x00000001009f2ee8 _dispatch_worker_thread3 + 114
19 libsystem_pthread.dylib 0x0000000100a6889a _pthread_wqthread + 1299
20 libsystem_pthread.dylib 0x0000000100a68375 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Further more mogenerator doesn't seem to respect the "Optional" flag or relationships:
It generates @NSManaged open var betas: NSSet which should be @NSManaged open var betas: NSSet?, no?
Additional Information
Xcode 8.3, mogenerator 1.31
A sample project can be found here: https://github.com/regexident/MogeneratorCrash
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels