rentzsch / mogenerator

Core Data code generation

Home Page:http://rentzsch.github.com/mogenerator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error importing "NSManagedObject.h" in XCode4/LLVM2.0

nomothetis opened this issue · comments

When I run mogenerator via the command line, the generated files have the following import statements:

#import <CoreData/CoreData.h>
#import "NSManagedObject.h"

These files can't compile, and, from looking at the template, it seems that mogenerator thinks NSManagedObject.h is the custom base class, which obviously isn't the case. Any idea if I'm doing something wrong? This is the complete command-line call I'm using:

mogenerator -m MyAppDataModel.xcdatamodel -M Classes/Generated/ -H Classes/

For reference, I am using XCode 4 Preview 5, with the Clang compiler that ships with it (LLVM 2.0).

Thanks!

huh, I don't know this issue here. Still a problem with Xcode 4 GM seed? If so, can you post your model file?

Yes, the problem is still there. It's kind of weird. Also, the inheritance isn't respected by the generator (unless I need to specify a flag of some kind). Where can I post the data model?

Get Dropbox and post a public url?

I'm seeing this with Mogen v1.26 and Xcode 4.4. Seems to be related to using abstract base classes.

@bengottlieb hmm, master's new test/ directory contains a model file with an abstract bas class (HumanMO) and it generates & compiles & runs sans issues. Can you repro the issue there? cd mogenerator/test && rake will do all the work of compiling new local mogenerator and running the tests.

I think I found the problem. If you explicitly pass in a base class, then it will #include it, even if it's NSManagedObject.

I ran into this issue due to a bug in Xcode. I was trying to generate code from several models that inherited from an abstract base entity. It turns out that although the Xcode model editor showed that the inheritance was setup correctly, the model file was actually corrupted in some way. You can see if this is the case by using Xcode's built-in generator and seeing the code that it generates. In my case, the generated code wasn't inheriting properly from the abstract base class.

I fixed this issue by manually going through each model, resetting the inheritance, and then saving the file. I was then able to get mogenerator to work again. Hope that helps someone.

@agmathew thanks for the followup!

I'm still seeing this issue - I have two entities that inherit from an abstract entity. The concrete entities have custom classes, the abstract entity does not.

I suppose I could generate a custom class for my abstract entity but I'm not sure why I should need to. Any ideas?

I again got this issue, but I was able to fix it by myself, when you create even abstract entity, or for inheritance, for properly work you MUST specify class field. http://take.ms/WFevx
I hope it will help somebody.