How to Understand Xcode Targets and Schemes for Build Configuration

How to Understand Xcode Targets and Schemes for Build Configuration

Written by

in

Quick answer: A target defines a single build product (app, framework, test bundle) with its own build settings and source files. A scheme defines which targets to build and how to run, test, profile, or archive them. Most projects have one scheme per app target, plus shared test targets.

Why this happens

Xcode projects expose two overlapping concepts—targets and schemes—that serve different purposes but appear together in the same UI. Apple’s documentation describes them in abstract terms, and the project navigator doesn’t visually separate them. Developers new to Xcode (or migrating from other IDEs) often confuse which one controls code inclusion, which one controls run actions, and why renaming a target can break schemes.

A target is the what: the list of source files, resources, build settings, and dependencies that produce one binary. A scheme is the how: the recipe that tells Xcode which targets to build for Run, Test, Profile, Analyze, and Archive, and which debugger, launch arguments, and environment variables to use. Confusing them leads to duplicate schemes, missing test targets, and broken archives.

How to fix it

1. Identify what each target produces

Open the project editor (select the project file in the navigator) and look at the Targets list. Each entry represents one build product:

  • App target – produces the .app bundle you run on device or submit to the App Store.
  • Framework target – produces a dynamic or static framework (.framework or .xcframework).
  • Unit test target – produces an .xctest bundle that runs against the app or framework.
  • UI test target – produces a separate .xctest bundle that drives the app from outside.
  • Extension targets – widgets, watchOS complications, intents, etc.

Each target owns its Build Phases (Compile Sources, Copy Bundle Resources, Link Binary With Libraries) and Build Settings (deployment target, Swift version, code signing). Adding a file to the project does not add it to every target—you must check the target membership box in the file inspector.

2. Understand what a scheme actually does

Click the scheme pop-up in the toolbar (next to the Run button) and choose Manage Schemes…. A scheme binds actions to targets:

Action Typical target(s) Purpose
Run App target Launches the app with the debugger attached.
Test Unit test + UI test targets Executes test bundles; can also build the app target first.
Profile App target Launches under Instruments.
Analyze App + framework targets Runs the static analyzer.
Archive App target Creates the .xcarchive for distribution.

A single scheme can reference multiple targets. For example, the default scheme for an app usually builds the app target for Run/Archive and the unit test target for Test. If you add a framework target, you may want a separate scheme that builds the framework for Run (to test it in a host app) and its own unit tests for Test.

3. Create or rename targets safely

To add a target: File → New → Target… Choose the template (iOS App, Framework, Unit Test Bundle, etc.). Xcode creates the target and a matching scheme (if “Autocreate Schemes” is on).

To rename a target: Select the target in the project editor, press Enter, type the new name. Xcode offers to rename the associated scheme and the product name (the binary). Accept both to keep them in sync. If you decline, update the scheme manually: Manage Schemes → select scheme → Edit → Info → set the correct executable for each action.

To share a target across schemes: In Manage Schemes, check the Shared column for each scheme that should be visible to other developers (and CI). Shared schemes live in xcshareddata/xcschemes/ and should be committed to version control.

4. Use “Autocreate Schemes Now” after bulk changes

If you add several targets at once (e.g., after generating a project with XcodeGen or Tuist), the scheme list can get out of date. Open Product → Scheme → Manage Schemes… and click Autocreate Schemes Now. Xcode scans all targets and creates a scheme for each one that doesn’t already have one. Delete any duplicates afterward.

5. Configure scheme-specific options for CI and local debugging

Edit a scheme (Product → Scheme → Edit Scheme…) to set:

  • Build Configuration per action (Debug for Run/Test, Release for Archive/Profile).
  • Launch Arguments and Environment Variables for feature flags or test mocking.
  • Diagnostics (Address Sanitizer, Thread Sanitizer, Malloc Scribble) for Test and Run actions.
  • Post-actions scripts (e.g., upload dSYMs to Sentry after Archive).

These settings live in the scheme, not the target, so you can have a “Debug” scheme and a “Release” scheme that build the same target with different configurations.

How to prevent it

  • Keep target names stable; rename only when the product identity changes.
  • Enable Autocreate Schemes in Manage Schemes for new projects.
  • Share all schemes used by CI (Shared checkbox) and commit the xcshareddata folder.
  • Use one scheme per distinct workflow (e.g., App-Debug, App-Release, Framework-Tests).
  • Document the target/scheme map in a README.md for onboarding.

FAQ

### Can a target belong to multiple schemes?

Yes. A unit test target is typically included in the Test action of every app scheme that exercises it, plus its own dedicated test scheme.

### Why does my new target not appear in the scheme pop-up?

The scheme hasn’t been created yet. Open Manage Schemes and click Autocreate Schemes Now, or manually create a scheme (click the + button) and add the target to the desired actions.

### Should I check “Shared” for every scheme?

Only for schemes that other developers or CI need. Private schemes (e.g., a local “Debug with Network Link Conditioner” variant) can stay unshared to avoid cluttering the team’s scheme list.

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.