Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 3.2.1 - Why are Core Data generated Classes resulting in Build errors?

It looks like the recent Xcode 3.2 has added some code generation niceties that (I think) were lacking pre-Snow Leopard.

I took the following steps:

  1. Define a simple .xcdatamodel model with a few entities, including one (inversible) one:many relationship (an Endpoint has many Subscription objects)

  2. File -> New and select the (icon-less) "Managed Object Class". From that wizard, I selected my classes and I was off to the races.

  3. Until, that is, I tried to build. I get this result and can't figure out:

Undefined symbols: "_OBJC_METACLASS_$_NSManagedObject", referenced from: _OBJC_METACLASS_$_Subscription in Subscription-B5BE258DF28BC03B.o _OBJC_METACLASS_$_Endpoint in Endpoint.o "_OBJC_CLASS_$_NSManagedObject", referenced from: _OBJC_CLASS_$_Subscription in Subscription-B5BE258DF28BC03B.o _OBJC_CLASS_$_Endpoint in Endpoint.o ld: symbol(s) not found collect2: ld returned 1 exit status

What I'd love help with:

  1. If anyone has any ideas of what I just did wrong, that'd be fantastic.

  2. It looks like the only way to get Xcode to *re-*generate your classes is to File -> New and replace them again, which (among other things) results in duplicate references to the new classes and your old class files uselessly left in a moved-aside folder in your project. Anyone know how to keep these in sync correctly? I haven't found any Apple documentation that covers the new stuff.

like image 678
Justin Searls Avatar asked Oct 11 '09 17:10

Justin Searls


1 Answers

Did you add the CoreData.framework to your project (or accidentally remove it)? That might be the source of the linking error.

Also, I reccomend you check out MOGenerator, by Wolf Rentsch. It's a much more powerful code generator for core data classes that uses the generation gap pattern. It can automatically regen classes every time you save the xcdatamodel while preserving your custom code.

like image 169
Barry Wark Avatar answered Nov 15 '22 07:11

Barry Wark