I have an iOS app containing a Core Data model with 6 entities. The entity Name
is set up as follows:
Class Name: Name
Module: Current Product Module
Codeine: Class Definition
(all 5 other entities are set up similarly).
Problem 1 (fixed itself but leaving for posterity)
Code IS generated in the derived data folder… not as ~class definitions as expected, but as extensions instead (named like Name+CoreDataProperties.swift
. It doesn't seem to matter whether the Codegen is set to Class Definition or Category/Extension - I still get the same result.
OK, hold that thought - all of a sudden both the class and extension files ARE now being generated… it looks like you need to delete the project's derived data folder and restart Xcode in between updates. Ignore Problem 1
Problem 2
Generated files ignore the data model Optional flag setting for String attributes and relationships - they are all generated as optionals
Problem 3 (fixed itself but leaving for posterity)
Ordered relationships are generated as OrderedSet
(and a compilation error) rather than NSOrderedSet
(can't change them as they get re-generated)
Workaround for me was to temporarily add to the project…
public typealias OrderedSet = NSOrderedSet
OK, now the compiler error has gone, and OrderedSet
seems to be recognised. Ignore Problem 3.
Problem 4
None of the above really matters, because the compiler can't find the files it's just generated. For the Name
entity above:
:0: error: no such file or directory: '/Users/ashleymills/Library/Developer/Xcode/DerivedData/-grfqveelvqtlydbpwjmfdietnrss/Build/Intermediates/.build/Debug-iphonesimulator/.build/DerivedSources/CoreDataGenerated//.Name+CoreDataClass.swift' :0: error: no such file or directory: '/Users/ashleymills/Library/Developer/Xcode/DerivedData/-grfqveelvqtlydbpwjmfdietnrss/Build/Intermediates/.build/Debug-iphonesimulator/.build/DerivedSources/CoreDataGenerated//.Name+CoreDataProperties.swift'
It's looking in derived data for files .Name+CoreDataClass.swift
and .Name+CoreDataProperties.swift
- notice the '.' at the front of the file names. (As a temp fix I added the generated files into the project)
I assume I'm doing something wrong, as if this was the case for everyone, no-one would be able to build a Core Data project… or are these bugs that need raising?
Cheers Ash
(Also raised on Apple dev forums)