I am just getting started with integrating mogenerator into an app project with Core Data, per recommendations as a best practice. I added the following build script, with a flag to support ARC.
mogenerator -m FavesDataModel.xcdatamodeld/FavesDataModel.xcdatamodel --template-var arc=true
The script successfully builds all the necessary classes and subclasses. At that time, I copied all the generated files into my project. Initially, I got a clean successful build. However, when trying another build (without making any changes), it fails with the following ARC error:
ARC forbids Objective-C objects in structs or unions
The errors occur in the files generated with an underscore. Interestingly, when the build script builds the files as follows:
extern const struct FavoriteAttributes {
__unsafe_unretained NSString *maxCFS;
__unsafe_unretained NSString *maxFeet;
__unsafe_unretained NSString *minCFS;
__unsafe_unretained NSString *minFeet;
__unsafe_unretained NSString *stationIdentifier;
__unsafe_unretained NSString *stationRealName;
__unsafe_unretained NSString *stationState;
} FavoriteAttributes;
However, after a successful build, XCode removes the __unsafe_unretained attribute.
Are there known issues with using mogenerator with ARC turned on? Any ideas of a solution or workaround? Thanks! V
Try removing --template-var arc=true from your build script.
Then in XCode, Project Properties, Compile sources, set the problem files to have the following flag
This will turn off ARC for only those files.