How do I use Mogenerator?

我与影子孤独终老i 提交于 2019-11-30 08:13:07

mogenerator is a script that is installed into your developer directory as I recall. However it might be installed into the Xcode scripts directory under your ~/Library.

What do you mean by manually triggering the application? You can trigger a build by "touching" the data model. Any save on the data model will trigger the build

In Xcode if you select the model file and hit ⌘I you will get its metadata. Click on the comments tab and add xmod there. mogenerator looks for that comment to know if it should generate files.

Update

You can run mogenerator from the command line as well as have it monitor your files. Type mogenerator --help in the Terminal to see the options.

One more caveat to be aware of: You have to already set the Class properties of your entities to something different than NSManagedObject. Otherwise Xmo'd won't do anything.

Note: Xmo'd currently doesn't work with Xcode 4/5, afaik.

What I do is just add a "MOGenerator" target in Xcode:

  1. Go to your project and click on "Add Target..." in the "Targets" section.
  2. Choose "iOS -> Other -> Aggregate"
  3. Go to "Build Phases"
  4. Select from the Menu "Editor -> Add Build Phase -> Add Run Script Build Phase"
  5. Paste your MOGenerator command into the Run Script section, for example:
PATH=${PATH}:/usr/local/bin    
cd "${PROJECT_DIR}/MyApp"
mogenerator --human-dir Classes --machine-dir MOGenerated --model MyApp.xcdatamodeld/MyApp.xcdatamodel --template-var arc=true

Now you can update your MOGenerator-generated by simply running this target.

I searched my hard drive and found the following files:

The application is installed to: /usr/bin/mogenerator.

The /Library/Application Support/mogenerator/ directory contains some .motemplate files.

Jake Lin

⌘I doesn't work in Xcode 4 any more. please check out the command line tool. Here is the doc

Studying line 22 of make_installer.command, I found that /Developer/Library/Xcode/Plug-ins/Xmod.pbplugin is also installed.

And then, searching mogenerator GitHub Issues for "uninstall," I found official instructions on how to uninstall mogenerator from the creator himself.

using mogenerator:

  1. download mogenerator

  2. run and build the mogenerator project

  3. locate the built file in the product group

  4. copy the built file in to /usr/bin directory

  5. in the terminal copy this code and hit enter: mogenerator -m /Users/hashem/Desktop/Projects/myApp/myAppModel.xcdatamodel -O /Users/hashem/Desktop/Projects/myApp/managedObjects --template-var arc=true

NOTE: here first I have entered myApp.xcdatamodel file path, and next path is the location of generated files. if the file path contains space character be sure to add \ character before space in the file path. like /desktop/xcode\ projects/myApp/....

enjoy!

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