Integrate mogenerator within Xcode 4

你。 提交于 2019-12-04 07:56:03

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.

Using mogenerator within Xcode 4 is quite simple.

First of all, download it at mogenerator.

Once done, switch to your Xcode project and, within the Project navigator, select your project (e.g. ProjectName). Select ProjectName under TARGETS section. Hold Add Build Phase. A menu appears. Select Add Run Script. A new run script will appear. Within the text area (under shell field), add some text like the following.

cd ProjectName mogenerator --template-var arc=true --model DataModel.xcdatamodeld/DataModel.xcdatamodel

Et voilà. When you build the project you should be able to see generated classes.

For other info and options you should refer to mogenerator wiki.

Hope it helps.

P.S. Feel free to comment or modify the answer if something is wrong.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!