dcep1
dcep1

Reputation: 261

Create NSManagedObject subclass not generating property after updating to Xcode 6.0

After updating to Xcode Version 6.0 (6A313), when I add a new attribute to my xcdatamodeld entry, "Create NSManagedObject subclass" is not adding the new property to the generated header file. This works fine after closing Xcode 6, and then running Version 5.1.1 (5B1008). I repeated this process a couple of times with the same results. Do I need to do something to allow a new Xcode version to properly manage my data models, or recreate them, or is this possibly just a bug with the new Xcode?

Here are the specific steps I took:
1. Open DataModel.xcdatamodeld in Xcode 6.0 (GM Seed).
2. Select correct entity
3. Click + to add new attribute
4. Enter name and selected Boolean type for new attribute
5. Editor->Create NSManagedObject subclass
6. Ensure proper data model is checked, click next
7. Ensure correct entity is checked, click next
8. Choose location to save (using root project folder), select Create
9. Choose "Replace" in dialogue box
10. Look for variable in generated header file. Variable not present.
11. Close Xcode6
12. Repeat steps 1-10 in Xcode 5.1.1, worked correctly
13. Repeated this process twice to verify same results

Thanks for any help!

Upvotes: 26

Views: 6610

Answers (5)

losiu
losiu

Reputation: 59

Old question. But here is my solution: just CLEAN it and BUILD again.

Menu: project > clean build folder and build again.

btw, here is the time of Xcode 9.

Upvotes: 0

Milos
Milos

Reputation: 2758

Before deleting your files and/or the data model itself as suggested, check whether you have added the module name in the Xcode's Data Model Inspector under Entity/Class. If you have, removing it will solve the problem of auto generating the entity classes. It will, however, reintroduce the problem you fixed by adding it in the first place (see Swift - CoreData: warning: Unable to load class named)... With this in mind, it appears a better solution to add the @objc(<ClassName>) above the generated class than to add the module name in the inspector.

Upvotes: 1

Ed Manners
Ed Manners

Reputation: 559

This requires a workaround, but specifically the quickest way I found was:

  1. Setup your project such that the generated files from the model, are in a folder of their own.

  2. When you need to add/change attributes to your model, multi-select the set of auto-generated files, and hit backspace (and select move them to Trash)

  3. Re-generate your set of NSManagedObject files from the Model, back into the same folder

Upvotes: 0

SpartaqUA
SpartaqUA

Reputation: 41

I had the same problem, Xcode didn't generate new properties after I choose "Replace" files.
Just fix it doing next steps:

  • after you change or add new entity in .xcdatamodel select changed entity Class files at "Groups & Files" list
  • select "Delete" - "Move to Trash" (if need copy specific code from your class file)
  • now back to .xcdatamodel and select entity you changed
  • create new NSManagedObject subclass(use standard way)

Upvotes: 0

d0n13
d0n13

Reputation: 942

Ok, I figured out a workaround but it would appear this is a bug.

For all the entities you want to regenerate, remove the existing files from disk try Editor->Create NSManagedObject subclass and select those classes that you have removed from disk.

The files that don't currently exist are regenerated. This fixed the issue for me.

Upvotes: 45

Related Questions