Question

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.

Était-ce utile?

La 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:

  • mogenerator did not actually run for some reason. Take a close look at the build log to make sure that it did.
  • mogenerator ran but failed for some reason. Again, check out the build log for signs of trouble.
  • mogenerator ran normally but you're either looking in the wrong place for its results or just not quite understanding the process.

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.

Autres conseils

I was having the same problem, build mogenerator, but no files would get generated. My problem was that I forgot to add a custom subclass to the .xcdatamodel

enter image description here

I checked my build log just like Tom mentioned above, which is how I saw the message "skipping entity SiteInfoGeneral (NSManagedObject) because it doesn't use a custom subclass"

Hope this is helpful to someone!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top