Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would Xcode not use the build configuration settings from my xcconfig file?

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"):

enter image description here

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.

like image 673
dmeyerson Avatar asked Sep 22 '15 23:09

dmeyerson


People also ask

How do I use Xcconfig files?

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.

How do I get Xcode build settings?

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.

How do I save build settings in Xcode?

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.

What is Xconfig 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.


1 Answers

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 */
like image 127
dmeyerson Avatar answered Nov 05 '22 11:11

dmeyerson