Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate mogenerator within Xcode 4

In my application I'm using Core Data stuff to enable persistent data saving. Since I've seen that mogenerator provides a good approach to create and maintain NSManagedObject subclasses (also with additional functionalities), I'm looking for some tips for integrating monogenerator within Xcode 4?

P.S. The question has been submitted based on share your knowledge, Q&A-style.

like image 463
Lorenzo B Avatar asked Nov 28 '12 16:11

Lorenzo B


1 Answers

For Xcode 4.5+, the easiest way is to setup a "Pre-action" in your scheme:

  1. Edit the scheme you want to build
  2. Open the "Build" item and select "Pre-actions"
  3. Click on the "+" and add a "New Run Script Action"
  4. In the "Provide build settings from" popup, use the target
  5. Paste this in the text area:

    # Update the mogenerator files  
    cd ${SOURCE_ROOT}/${PROJECT_NAME}  
    /usr/bin/mogenerator --template-var arc=true -m ${PROJECT_NAME}.xcdatamodeld -M CoreData/Machine -H CoreData/Human`
    
  6. Hit "OK" and build

A directory named "CoreData" will be created in your source file area along with the subdirectories "Human" and "Machine". You should now add the "CoreData" folder to your project.

like image 130
Dan Waylonis Avatar answered Sep 21 '22 12:09

Dan Waylonis