Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Core Data code generation causes build failure

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.

like image 765
Adam Carter Avatar asked Jun 17 '26 20:06

Adam Carter


1 Answers

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!

like image 68
Adam Carter Avatar answered Jun 20 '26 20:06

Adam Carter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!