Duplicate Errors in Linking

MacOS 15, 14 target. Latest XCode.


I created a new non-document CoreData app using XCode template. Added in two persistent classes, FileServers and Server, from another (previously working) app to isolate some issues. No other model objects. I get 4 errors, one for each class and meta class:


duplicate symbol '_OBJC_CLASS_$_FileServers' in:

/Users/gordonapple/Library/Developer/Xcode/DerivedData/SimpleSFTPClient-bknoaunyaxmtbnatoytyifidspjy/Build/Intermediates.noindex/SimpleSFTPClient.build/Debug/SimpleSFTPClient.build/Objects-normal/x86_64/FileServers.o

/Users/gordonapple/Library/Developer/Xcode/DerivedData/SimpleSFTPClient-bknoaunyaxmtbnatoytyifidspjy/Build/Intermediates.noindex/SimpleSFTPClient.build/Debug/SimpleSFTPClient.build/Objects-normal/x86_64/FileServers+CoreDataClass.o


Next attempt: Deleted the two managed object classes and used XCode's "Create Managed Objects Subclasses" and get:


Showing All Messages

Multiple commands produce '/Users/gordonapple/Library/Developer/Xcode/DerivedData/SimpleSFTPClient-bknoaunyaxmtbnatoytyifidspjy/Build/Intermediates.noindex/SimpleSFTPClient.build/Debug/SimpleSFTPClient.build/Objects-normal/x86_64/Server+CoreDataProperties.o':

1) Target 'SimpleSFTPClient' (project 'SimpleSFTPClient') has compile command with input '/Users/gordonapple/Ed4U Projects/SimpleSFTPClient/SimpleSFTPClient/SimpleSFTPClient/Model/Server+CoreDataProperties.m'

2) Target 'SimpleSFTPClient' (project 'SimpleSFTPClient') has compile command with input '/Users/gordonapple/Library/Developer/Xcode/DerivedData/SimpleSFTPClient-bknoaunyaxmtbnatoytyifidspjy/Build/Intermediates.noindex/SimpleSFTPClient.build/Debug/SimpleSFTPClient.build/DerivedSources/CoreDataGenerated/SimpleSFTPClient/Server+CoreDataProperties.m'


Any idea what is going on here?

Replies

Xcode projects that use Core Data default to automatically generating classes for Core Data entities. When you manually create the NSManagedObject subclasses or copy them from another project, you end up with duplicate classes.


The solution is to either remove your NSManagedObject subclasses from the project or turn off Xcode's class generation. To turn off the class generation, open the data model inspector for the entity and choose Manual/None from the Codegen menu. For more detailed information as well as screenshots, read the article at the following URL:


swiftdevjournal.com/core-data-code-generation/

I'm not sure what you are saying. I should have mentioned that this is Objective C. I copied the two entities into my (graphic) model, then used "Create NSManagedObject Subclasses", which created four files for each entity.. So where are the duplicates?

The duplicates, the class files Apple generates automatically, are in the Derived Data folder. You're not meant to access them.


Please reread my previous response and read the article I linked to in that response. The article provides a detailed explanation of the problem you're facing.

Ok, got it. Looks like some new stuff I hadn't delt with before. Thanks.

-ld64