I updated my iOS app project recently to iOS 10. Now I\'m trying to change the Core Data Model of my app but the new NSManagedObject subclasses which Xcode generates are bro
I'm putting my grain of salt given that I can see a lot of answers that solve the problem but are lacking the real reason behind what's really happening here.
I stumbled upon this very same issue and by doing a quick research I was able to find that:
Until Xcode 7, the default behavior for a Core Data entity was that the developer had to manually create and maintain the changes of the corresponding NSManagedObject subclasses. (This could, and still can be accomplished by making use of the editor menu selecting the "Create NSManagedObject subclass.." option).
Starting from Xcode 8, Apple has included a new setting right in the Data Model Inspector named Codegen to manage and maintain the NSManagedObject subclasses. The default value for this setting is "Class Definition" which tells Xcode to generate the NSManagedObject subclasses based on our defined entities in compile time and put them in the derived data folder.
Having our NSManagedObject subclasses within the project + the ones Xcode automatically generates lead us to the real reason behind the "Multiple commands produce..." compiling time error as we now have duplicated managed objects models!!!
The solution then is to use either one or another, not both! I personally prefer to have my managed object models within the project so I have changed this "Codegen" setting to "Manual/None". If you are not adding logic to the models I bet you could opt by removing your project's managed object models and let Xcode do its thing based on the "Class Definition" value for the mentioned setting. This is the right way to deal with this issue.
You can find a great article explaining all of this in detail here:
https://medium.com/@kahseng.lee123/core-data-codegen-explained-462c30341041