9

The title pretty much contains the question. We released an app with a data model that had their inverses improperly configured. We fixed these in the next release with a new version of the data model, but Xcode still displays the warnings when compiling the previous data model version.

I don't want want to break the ability to migrate documents from the old data model to the new data model and I'm pretty sure that changing the inverses in the old data model will do just that. So, I'm wondering if there's a way to suppress that warning for just that file - I'm concerned somebody else might come along, see the warning, and decide to "fix" it.

Edit: Based on pe8ter's comments, it looks like I want to specify the MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS option for a single revision of the data model. I don't want to turn it off project-wide or even model bundle-wide because I want the warnings to appear if people make this same mistake in the future.

Jablair
  • 5,036
  • 4
  • 28
  • 37
  • 1
    Did you try messing with the Core Data settings in your target's build settings? There's one in there about suppressing warnings for no inverse relationship. – pe8ter Jan 05 '12 at 02:48
  • I'd missed them in the project setting, but it looks like I want to disable MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS. Unfortunately, I don't see a way to do it just for a single model revision. The whole model bundle is compiled; the individual revisions aren't compiled separately. Even if they were, MOMC seems to ignore single-file compiler options specified in Build Phase. – Jablair Jan 05 '12 at 16:09
  • I have this same problem because Apple introduced new warnings in a new XCode version that were previously not caught. Seems I will use -w on the whole model and checking for warnings when I release to the public. – Bjinse Aug 01 '13 at 20:37

2 Answers2

2

Since you're only including the file for backwards compatibility, and therefore you don't want it to ever change, I would recommend checking the already compiled file into source control and using a Copy Files build phase to put it in the correct place.

Since we're just talking about a single revision in a bundle, you might need to keep an empty, dummy version in the model source (so it gets the numbering right). Then your Copy Files phase would just overwrite it.

benzado
  • 82,288
  • 22
  • 110
  • 138
1

I can't say I've ever needed to do this myself, but you could try writing a script that runs the momc compiler on your old data model with MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS set as you like. Then add a Run Script build phase to run the script when you build. You may need to remove your old data model from your target to prevent Xcode from trying to compile it too. You can use the Copy Bundle Resources build phase to include the compiled model in your built application.

Before you can write that script, you'll have to find the momc model compiler. This page says it's at Library/Xcode/Plug-ins/XDCoreDataModel.xdplugin/Contents/Resources/, but it seems to have moved for Xcode 4.

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • Looks like momc is located at /Developer/usr/bin/momc, or wherever you have Xcode installed. However, I don't think this will work. momc compiles the whole xcdatamodeld bundle as a single entity instead of doing separate compiles for *_v1.xcadatamodel, *_v2.xcdatamodel, etc. In this case, I want to ignore warnings on *_v2, but keep them enabled for future revisions. – Jablair Jan 05 '12 at 22:21
  • Last ditch effort: remove your old model from the target so that Xcode builds all the models but that one with warnings on. Use a script build phase to compile all the models, including the old one, and use the result to replace the model that Xcode builds. If that doesn't work, I'd have to think the answer is "no, there's no way to change momc settings for a single file." Good luck. – Caleb Jan 05 '12 at 22:36