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
.
Creating and using your xcconfig file To create an xcconfig file, choose File -> New -> File... in your project. In the new file dialog, scroll down until you see the Configuration Settings File in the Other section. You can add configurations for pretty much anything you want.
Choose the project in the Project Navigator on the left. Select the Configurations target from the Targets section and click the Build Settings tab at the top. The Build Settings tab shows the build settings for the Configurations target. It's possible to expand this list with build settings that you define.
You will have to copy the build settings from your xcodeproj file. Open your xcodeproj file in a text editor and copy: buildSettings = { ... } Into your xcconfig file.
Xcode build configuration files, more commonly known by their xcconfig file extension, allow build settings for your app to be declared and managed without Xcode. They're plain text, which means they're much friendlier to source control systems and can be modified with any editor.
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 */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With