Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying a subproject's Configuration in Xcode

I have an Xcode project (A) referencing another project (B). By default (as far as I understand it) Xcode will implicitly build the configuration for the B dependency that matches the configuration of the A's target (e.g., "Debug"). But what if I want, say, A to build as "Debug" and the B to build as "Release"? How would I go about specifying that in Xcode?

like image 716
fbrereto Avatar asked Oct 23 '09 18:10

fbrereto


People also ask

Where is the build Settings tab in Xcode?

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.


4 Answers

I don't know of any easy approach, but you can brute-force it by calling xcodebuild directly for the dependency with a "Run Script" build phase.

I know it was just an example, but if your real goal is that the sub-project be a Release (no symbols) build, then you may have a better experience by just building the sub-project into a library or framework and checking the resulting binary into your version control system. Whenever I have a piece of the system that seldom changes and that I don't want debug symbols for, I go ahead and build it as a static library and check it in. I often go ahead and move the code elsewhere as well (with a README file with the .a that says where the code is and how it was built). This saves time on both build and checkout and is invaluable for large projects in my experience.

like image 72
Rob Napier Avatar answered Oct 12 '22 23:10

Rob Napier


This might help: if the configuration of the project A is not found, Xcode will build Release config as a fallback (or maybe the first config of the list).

Then you can "force" the link using this tip: Xcode custom build configuration causes "library/file not found" for static libraries

like image 34
MonsieurDart Avatar answered Oct 13 '22 01:10

MonsieurDart


Yes, this is not naturally supported by Xcode; when you build a target, it builds one configuration of itself and of all dependent targets.

The workaround, as Rob mentioned, is to have a dependent target that's an Aggregate Target type that comprises a single Run Script build phase, which simply invokes xcodebuild -configuration Release (or whatever).

like image 28
cdespinosa Avatar answered Oct 13 '22 01:10

cdespinosa


You can specify the default 'fallback' configuration in the project info.

Change from:

Use 'Release' for command-line builds.

to:

Use 'Debug' for command-line builds.

And default will be 'Debug'.

Diffs of project file: Diffs of project file

like image 23
Sam Avatar answered Oct 13 '22 00:10

Sam