31

There was a MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS setting on Xcode 3 but I cannot find it in Xcode 4.2 and trying to set it as a user defined build setting have no effect.

I know why I should use inverse relationship but I just don't want it for various reasons.

Bryan Chen
  • 45,816
  • 18
  • 112
  • 143
  • I know you say you know why you should use an inverse relation but I'm just checking. You know that it simplifies for CoreData if there is a reverse relationship and that not having it can reduce performance, e.g. when cascading deletes? Because it is recommended to always have a inverse relationship, even if you never use it. Of course you may have some special use case where the inverse is actually bad for you, in which case a one-way relationship _may_ be the better option. – David Rönnqvist Nov 22 '11 at 21:23
  • @David Rönnqvist I have an EntityA that have to relationships: allItems and mostRecentlyUsed. allItems is a to-many and mostRecentlyUsed is to-one and both points to EntityItem. I cannot see any reason that to make EntityItem have two inverse relationship both point to a same EntityA. – Bryan Chen Nov 24 '11 at 09:49
  • I agree theres no reason we "should" have inverse relations. I mean, since when is it mandatory for every "getChild" relationship to have a corresponding "getParent" in an object oriented progam? And btw, did you find a solution yet- I want it too – Rhubarb Oct 01 '12 at 11:21

3 Answers3

39

In XCode 5, 6 and 7, you can still set the variable.

  1. Navigate to Build Settings

    A. Select your project on the left side bar under Project Navigator.

    B. Select the "Build Settings" tab.

  2. Find and set MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS

    A. Select 'All' in the upper left of the main screen.

    B. Search for MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS by pasting the key into the search bar.

    C. Change value to YES.

Build again and the warnings are gone.

****EDIT****

Thanks @RajTandel for the comment. If you still see the warnings, restart Xcode and the warnings should go away.

mikeho
  • 6,790
  • 3
  • 34
  • 46
  • @mikeho your steps are correct. Thanks, But in Xcode 7.2 warnings still exist even if i clean and build it. so i have to restart Xcode and all warnings were gone. – Raj Tandel Mar 25 '16 at 06:02
37

Using XCode 4.3:

Find your way to Build Settings

  1. Select project node (top node) in the project Navigator

  2. Select your project under Targets

  3. Select the "Build Settings" tab

Find and set the MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS setting

  1. Scroll all the way down the build settings to near the bottom and find the section named "Data Model Version Compiler (MOMC) Warnings"

  2. The first entry is "MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS" and it defaults to NO

  3. Change it to YES

Build again, and the warnings should vanish.

Rhubarb
  • 34,705
  • 2
  • 49
  • 38
3

The setting is still there in Xcode 4. At least it is for me when I create a new project in Xcode 4.2 that uses Core Data. The MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS setting is in the Data Model Version Compiler (MOMC) Warnings collection, which is towards the bottom of the build settings list.

Swift Dev Journal
  • 19,282
  • 4
  • 56
  • 66
  • I cannot find anything like Data Model Version Compiler (MOMC) Warnings collection, search 'momc' in build settings give me nothing. Is this because I didn't create my project using the Core Data template? I used cocos2d template to create the project. – Bryan Chen Nov 24 '11 at 00:17
  • I haven't used cocos2d, but the fact you didn't use the Core Data project template could be the cause of your not having a Data Model Version Compiler Warnings collection. One other thing to check is the Basic and All buttons above the list of build settings. Make sure you click the All button. – Swift Dev Journal Nov 24 '11 at 02:28
  • 1
    I did click the All button and still cannot find and I create a new project that using Core Data template and it is there. I guess these build settings will only appear if I create my project using Core Data template. But there should be someway to enable these settings without create the project using Core Data template. – Bryan Chen Nov 24 '11 at 09:43