Search code examples
objective-cxcodecore-datansmanagedobject

Regenerate NSManagedObject subclasses on build


I have searched a bit but I cannot find an easy way to tell xcode to regenerate all the NSManagedObject subclasses on build. I would do this to be able to take all those classes off our git repository and only committing the model, and at the same time be sure that no one runs into problems because the classes are not in sync with the model


Solution

  • If you use something like mogenerator (http://rentzsch.github.com/mogenerator) to generate your model classes, you can get it to run as a script as per above suggestion.

    This way, every time you trigger a build, the mogenerator script will run first making sure your classes have been updated according to the object model file.

    Here's a good article to guide you through it http://www.esenciadev.com/2011/05/mogen-and-xcode4-integration/