Fix: Multiple Build Commands for Output File Warning in Xcode

Fix: Multiple Build Commands for Output File Warning in Xcode

Written by

in

Quick answer: The ‘Multiple build commands for output file’ warning occurs when the same resource file appears twice in your target’s Copy Bundle Resources build phase. Fix it by opening the target’s Build Phases tab, expanding Copy Bundle Resources, locating the duplicate file entries, and removing one reference.

Why this happens

Xcode emits the “Multiple build commands for output file” warning when the build system detects that two separate build steps would write the same file into the built product. The most common cause is a resource file—typically an image, font, or data file—listed twice in the Copy Bundle Resources build phase of a target.

This duplication can happen in several ways:

  • Dragging a file into the project navigator twice without noticing
  • Merging Git branches where both sides added the same asset
  • Running a script or CocoaPods install that re-adds resources already present
  • Manually editing the .pbxproj file and accidentally creating two PBXBuildFile entries for the same PBXFileReference

Even though the Project Navigator shows only one reference (because both build-file entries point to the same file reference), the build phase actually contains two distinct PBXBuildFile objects. The build system therefore schedules two copy operations for the identical destination path, triggering the warning.

How to fix it

1. Remove the duplicate from Copy Bundle Resources (recommended)

This is the cleanest fix and matches the highest-voted community solution.

  1. In the Project Navigator, click the project file (top-level, blueprint icon).
  2. Select your target in the center column.
  3. Open the Build Phases tab.
  4. Expand Copy Bundle Resources.
  5. Type the warned filename (e.g., no.png) in the filter box at the bottom of the list.
  6. You will see two rows referencing the same file.
  7. Select one of the duplicate rows and press Delete (or right-click → Remove).
  8. Build the project (⌘B). The warning should disappear.

Tip: If you have many duplicates, sort the list by name (click the Name column header) to spot adjacent pairs quickly.

2. Delete and re-add the file via Project Navigator

If you prefer working in the navigator, the accepted Stack Overflow answer describes this approach:

  1. In the Project Navigator, use the search field (⌘⇧O) to find the problematic filename.
  2. Xcode shows a single entry—this is the file reference, not the build-file entries.
  3. Delete that reference (press Delete, choose Remove Reference when prompted).
  4. Drag the actual file from Finder back into the navigator, ensuring “Copy items if needed” is checked and your target is ticked.
  5. Build again.

This works because removing the file reference also removes all associated build-file entries; re-adding creates exactly one.

3. Clean the build folder (if warning persists)

Stale build artifacts can sometimes keep the warning alive after the duplicate is gone:

  1. Product → Clean Build Folder (⌘⇧K).
  2. Build again.

How to prevent it

  • Enable “Show Build Phases” in the Project Navigator (right-click → Show Build Phases) so you can visually scan Copy Bundle Resources occasionally.
  • Use version-control diffs before committing: git diff --name-only will reveal if the same asset was added in two commits.
  • Adopt asset catalogs (.xcassets) for images and colors; they are managed as a single bundle entry.
  • Avoid manual .pbxproj edits; resolve merge conflicts in the project file with Xcode’s built-in resolver or git mergetool.
  • Run xcodebuild -showBuildSettings in CI to catch duplicate PBXBuildFile entries early.

FAQ

Does this warning affect the final app binary?

No. The warning only indicates redundant work during the copy phase. The resulting .app bundle contains a single copy of the file, so runtime behavior is unchanged. However, treating warnings as errors (GCC_TREAT_WARNINGS_AS_ERRORS = YES) will fail the build.

Why does the Project Navigator show only one entry?

The navigator displays file references (PBXFileReference). A single file reference can be referenced by multiple build files (PBXBuildFile) in different build phases—or even twice in the same phase. The navigator does not expose build-file multiplicity.

Can a Run Script phase cause the same warning?

Yes. If a Run Script phase copies a file to the same destination that Copy Bundle Resources uses (e.g., ${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/logo.png), you will see the identical warning. The fix is to remove the manual copy or move the file out of Copy Bundle Resources.

Summary

The “Multiple build commands for output file” warning is almost always caused by a duplicate entry in Copy Bundle Resources. Open the target’s Build Phases tab, filter for the named file, and delete the extra row. Clean the build folder if needed, and adopt asset catalogs or careful Git hygiene to prevent recurrence.

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.