EDIT: I figured one could have this problem with any build configuration setting, not just OTHER_LDFLAGS
and I've changed the title accordingly and removed irrelevant details from the question.
I have a simple Xcode project MyApp. MyApp.xcconfig is set as the configuration file for Debug builds. It has one line:
OTHER_LDFLAGS = -force_load /foo/bar
Though it knows MyApp.xcconfig sets OTHER_LDFLAGS
Xcode doesn't want to use that setting. A blank space, instead of the value in MyApp.xcconfig, is highlighted in green in the build settings (see the bottom rows labelled "Other Linker Flags"):
Why is this the case? From what I've read, it seems like the resolved setting should be the one from the .xcconfig file. Is there a way to make it so?
I've also found that other settings in the xcconfig do resolve. But not OTHER_LDFLAGS
.
The problem build setting (in this case OTHER_LDFLAGS
) is being assigned an empty string, ""
, in MyApp's project.pbxproj
file. Xcode sees that assignment and instead of ignoring it, overwrites your xcconfig setting. The solution is to delete the line in project.pbxproj
.
• From the command line, open MyApp.xcodeproj/project.pbxproj
in a text editor, e.g. Vim. In it you'll see Xcode keeps a bunch of information needed to build MyApp, including build configuration settings that you set in Xcode's UI.
• Scroll to the XCBuildConfiguration section
. There you'll see your problem build setting (in this case OTHER_LDFLAGS
) being assigned an empty string. Delete that line and save the file.
/* Begin XCBuildConfiguration section */
.
.
.
3729FD9E18B776ECB0A1990 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 4820F7A08BBB17C8164733A /* MyApp.xcconfig */;
buildSettings = {
/// delete this line ///
OTHER_LDFLAGS = "";
};
name = Debug;
};
.
.
.
/* End XCBuildConfiguration section */