iosxcodecore-dataxcode5mogenerator

Using Mogenerator with Xcode 5


I am trying to use Mogenerator with Xcode 5 but it is generating only one set of ManagedObject class (.h and .m) files instead of two set of (Machine and Human) files. I have tried many tutorials already but no use so far. If anyone could provide a step by step guide to use Mogenerator with Xcode 5 would be really helpful.

I followed the procedure mentioned in the below link. http://adoptioncurve.net/archives/2012/12/setting-up-mogenerator-in-xcode-4-dot-5/

These are the steps I followed,

  1. Installed 'Mogenerator'
  2. Added new mogenerator target.
  3. Selected 'New Mogenerator' target and then selected 'Build Phases'.
  4. Then from the Editor tab --> Add Build Phase --> Add Run Script Build Phase
  5. Opened Run Script section on 'Mogenerator' target and edit the script like this mogenerator -m MyCoreDataApp/MyCoreDataApp.xcdatamodeld -O MyCoreData/Model --template-var arc=true
  6. Selected 'Main' target and added Target dependency as Mogenerator.
  7. Selected the 'Entity' on the Core Data file (xcdatamodeld) and then selected Editor --> Create NSManagedObject Subclass.
  8. Checked 'Main' target in the popup window. (Even tried selecting 'Mogenerator' target).

Only two files, which are NSManagedObject subclasses (.h and .m) are being recreated.

Please let me know if I missed any steps in the process.


Solution

  • First, your steps 7 and 8 should be unnecessary. You're duplicating steps that mogenerator is supposed to be taking. You should not be taking those steps, and you should delete the files that you created using those steps. Creating those files is mogenerator's job, when you're using it.

    The results you describe suggest one of the following scenarios:

    If mogenerator works normally, it generates two class files for each entity in the model. But it does not automatically add the files to your Xcode project. If the files are already part of the project then Xcode uses the new versions. But if they're new files, you need to add them to the project before Xcode will notice them. If this is the case, then your mogenerator command means that the files are located in MyCoreData/Model just waiting for you to find them.