CoreData in Objective-C in Xcode 11


Alex Zavatone
 

I’m going through Chris Eidhof’s Core Data tutorial here https://www.objc.io/issues/4-core-data/full-core-data-application/ and noticed something that ends up creating a build error directly after creating creating a simple ManagedObjectModel from the Editor > Create NSManagedObject Subclass.

Two Swift files are created, not Objective-C files.

Item+CoreDataProperties.swift
Item+CoreDataClass.swift

The creation of these classes create a build errors right away.  Is it expected that an Objective C project will create Swift MOC subclasses?  Is anyone using CoreData in Xcode 11?
I’m curious what’a happening here.

Thanks.


<unknown>:0: error: filename "Item+CoreDataClass.swift" used twice: '/Users/zav/Developer/BasicCoreData/BasicCoreData/Item+CoreDataClass.swift' and '/Users/zav/Library/Developer/Xcode/DerivedData/BasicCoreData-ddewwduzsmelbzawnlblirktothl/Build/Intermediates.noindex/BasicCoreData.build/Debug-iphonesimulator/BasicCoreData.build/DerivedSources/CoreDataGenerated/ItemModel/Item+CoreDataClass.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
<unknown>:0: error: filename "Item+CoreDataProperties.swift" used twice: '/Users/zav/Developer/BasicCoreData/BasicCoreData/Item+CoreDataProperties.swift' and '/Users/zav/Library/Developer/Xcode/DerivedData/BasicCoreData-ddewwduzsmelbzawnlblirktothl/Build/Intermediates.noindex/BasicCoreData.build/Debug-iphonesimulator/BasicCoreData.build/DerivedSources/CoreDataGenerated/ItemModel/Item+CoreDataProperties.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name


error: Multiple commands produce '/Users/zav/Library/Developer/Xcode/DerivedData/BasicCoreData-ddewwduzsmelbzawnlblirktothl/Build/Intermediates.noindex/BasicCoreData.build/Debug-iphonesimulator/BasicCoreData.build/Objects-normal/x86_64/Item+CoreDataClass.o':
1) Target 'BasicCoreData' (project 'BasicCoreData') has compile command for Swift source files
2) Target 'BasicCoreData' (project 'BasicCoreData') has compile command for Swift source files

error: Multiple commands produce '/Users/zav/Library/Developer/Xcode/DerivedData/BasicCoreData-ddewwduzsmelbzawnlblirktothl/Build/Intermediates.noindex/BasicCoreData.build/Debug-iphonesimulator/BasicCoreData.build/Objects-normal/x86_64/Item+CoreDataProperties.o':
1) Target 'BasicCoreData' (project 'BasicCoreData') has compile command for Swift source files
2) Target 'BasicCoreData' (project 'BasicCoreData') has compile command for Swift source files


–––––––––––––––––––––

Item+CoreDataClass.swift


import Foundation
import CoreData

@objc(Item)
public class Item: NSManagedObject {

}


–––––––––––––––––––––

Item+CoreDataProperties.swift


import Foundation
import CoreData


extension Item {

    @nonobjc public class func fetchRequest() -> NSFetchRequest<Item> {
        return NSFetchRequest<Item>(entityName: "Item")
    }

    @NSManaged public var order: Int64
    @NSManaged public var title: String?
    @NSManaged public var parent: Item?
    @NSManaged public var child: Item?

}




Join cocoa@apple-dev.groups.io to automatically receive all group messages.