How to Print Every Xcode Build Setting from the Command Line

Written by

in

Quick answer: Run xcodebuild -showBuildSettings in the project directory, adding -scheme or -target and the same -configuration and -sdk as your build. It prints each resolved setting as NAME = value; pipe the output through grep for a single key. Run Script phases receive the same values as environment variables.

Why this happens

Xcode build settings are not a fixed table. The value of a setting is resolved when a specific target is built for a specific SDK, configuration, and destination. Xcode layers its built-in defaults, project-level settings, target-level settings, xcconfig files, and any command-line overrides. A setting that exists for an app target may not exist for a static library, and an archive build can resolve paths differently from a Debug simulator build.

That is why old canonical-list posts age badly. A dump captured from Xcode 4.1 tells you what that version produced for one target, not what your project uses today. The reliable source is the build system itself.

How to fix it

1. Dump every resolved setting with xcodebuild

Open Terminal in the directory that contains your project or workspace and run:

xcodebuild -showBuildSettings

If the directory has more than one project, or you want to be explicit:

xcodebuild -project MyApp.xcodeproj -target MyApp -showBuildSettings

For a workspace and scheme:

xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -showBuildSettings

The output is a list of NAME = value pairs. That is the resolved value for the target, configuration, and platform xcodebuild picked. Add flags to match the build you care about:

xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -configuration Release -sdk iphoneos -destination 'generic/platform=iOS' -showBuildSettings

-configuration and -sdk matter. A Debug simulator build and a Release device build can have different BUILT_PRODUCTS_DIR, CODE_SIGN_IDENTITY, SWIFT_OPTIMIZATION_LEVEL, and dozens of other values.

2. Filter to the setting you need

The full dump is long. Pipe it through grep:

xcodebuild -scheme MyApp -showBuildSettings | grep -E '^ *(PRODUCT_BUNDLE_IDENTIFIER|SWIFT_VERSION|IPHONEOS_DEPLOYMENT_TARGET) *='

If you want only the value:

xcodebuild -scheme MyApp -showBuildSettings | awk -F ' = ' '/^ *PRODUCT_BUNDLE_IDENTIFIER / { print $2; exit }'

This is useful in CI scripts where you need the bundle identifier or the built products directory without parsing the whole log.

3. Read the same values inside a Run Script phase

Build settings are exported as environment variables to Run Script phases and Build Rules. You do not need to call xcodebuild from inside the build. Add a Run Script phase and print what you need:

#!/bin/sh
set -e

echo "Configuration: $CONFIGURATION"
echo "Bundle ID: $PRODUCT_BUNDLE_IDENTIFIER"
echo "Built products: $BUILT_PRODUCTS_DIR"
echo "Target name: $TARGET_NAME"

Use the variable name exactly as it appears in the build settings list. If a value contains spaces, quote it in shell ("$BUILT_PRODUCTS_DIR"). To fail the build when a required setting is empty:

#!/bin/sh
set -e

if [ -z "$PRODUCT_BUNDLE_IDENTIFIER" ]; then
  echo "error: PRODUCT_BUNDLE_IDENTIFIER is empty"
  exit 1
fi

4. Check the build log for the resolved command line

When a setting seems to be ignored, look at what Xcode actually passed to the compiler or linker. In Xcode, build the project, open the Report navigator, select the build, and expand the step you care about. The log shows the full command line with resolved flags. This catches cases where a setting is defined but overridden later, or where the value is not used by that particular step.

5. Know where the value came from

If a setting has an unexpected value, check these sources in order:

  • A command-line override passed to xcodebuild, such as PRODUCT_BUNDLE_IDENTIFIER=com.example.other.
  • The target’s Build Settings tab.
  • The project’s Build Settings tab.
  • An .xcconfig file assigned to the project or target.
  • Xcode’s default build settings for that SDK and target type.

The first match wins. A value in the target’s build settings overrides the project-level value, and a command-line override beats both. If you use xcconfig files, open the file and search for the setting name; a typo there is easy to miss.

How to prevent it

  • Do not copy a static list of build settings from an old blog post or Stack Overflow answer. Dump the settings from the project you are building.
  • Match the configuration, SDK, and destination to the build you are debugging. A simulator Debug dump is not an archive dump.
  • Keep shared values in .xcconfig files and review changes to them, instead of scattering overrides across targets.
  • In CI, print the resolved settings once at the start of the job so the log records what the build used.
  • Pin the Xcode version in CI. Build setting names and defaults can change between Xcode releases.
  • Prefer documented settings. If a setting is not in Apple’s build settings reference and not in the dump, do not depend on it.

FAQ

Is there a canonical list of Xcode build settings?

No single list covers every project. Apple documents many settings, but the resolved set depends on the target type, SDK, configuration, and Xcode version. xcodebuild -showBuildSettings is the authoritative list for your build.

Why does xcodebuild -showBuildSettings show a different value than Xcode?

The command resolves settings for the target, scheme, configuration, and destination you gave it. Xcode may be building a different scheme or configuration, or a command-line override may be in effect. Run the command with the same -scheme, -configuration, and -sdk values, and check for overrides.

Can I use build settings as environment variables in a Run Script phase?

Yes. Xcode exports build settings to Run Script phases and Build Rules as environment variables. Use the exact setting name, quote values that may contain spaces, and check for empty values if the script depends on them.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.