Reputation: 4844
I’m using the new Xcode 8 feature of code generation for my Core Data model using Class Definition
as the Codegen
option.
When I build I get the following output for each of my entities:
<unknown>:0: error: no such file or directory: ‘/path/to/DerivedSources/CoreDataGenerated/Model/.Entity+CoreDataClass.swift'
<unknown>:0: error: no such file or directory: ‘/path/to/DerivedSources/CoreDataGenerated/Model/.Entity+CoreDataProperties.swift’
...
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
On inspecting the files I can see the following:
Entity+CoreDataClass.swift:
import Foundation
import CoreData
public class Entity: NSManagedObject {
}
Entity+CoreDataProperties.swift
import Foundation
import CoreData
import
extension Entity {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Entity> {
return NSFetchRequest<Entity>(entityName: “Entity");
}
@NSManaged public var title: String?
}
In the second, the obvious thing that shouldn’t be there is the empty import statement, which I’m guessing is causing the crash.
Could I be doing something wrong? Is this a bug?
I’ve tried all the usual, clean, clean build folder, restart Xcode/Mac with no luck.
Upvotes: 3
Views: 1990
Reputation: 4232
Core Data is heavily string-based. Using names such as "Entity" for your entities can lead to unexpected results. Also avoid using names in your data model such as "description", or "item" or "attribute" etc. If you do want to use those names, prefix them: names like "My_entity" or "ACEntity" are fine.
Upvotes: 0
Reputation: 4844
The Module
field of the entity in the Data Model inspector had a value in it, I deleted this so now it’s empty and the placeholder reads “Global namespace”. This seems to have worked!
Upvotes: 2