xcodebuild "Multiple commands produce" in CI
Two build tasks claim to produce the same output file, and Xcode's build system refuses to guess which one wins. This commonly comes from a resource listed twice or a file present in both Copy Bundle Resources and Compile Sources.
What this error means
xcodebuild fails with "error: Multiple commands produce '.../App.app/config.json'" naming the duplicated output and the two tasks that produce it.
error: Multiple commands produce
'/Users/runner/.../App.app/config.json':
1) Target 'App' has copy command from '.../config.json'
2) Target 'App' has copy command from '.../Resources/config.json'Common causes
A resource added to the target twice
The same file is referenced in two places (two folder references, or a file plus a folder that contains it), so both copy it to the same output.
A file in both Compile Sources and Copy Bundle Resources
A source or asset listed in both phases produces the same output from two commands.
How to fix it
Remove the duplicate reference
- Read the two producing commands the error names.
- In the target's Build Phases, remove the file from one of the two phases or folder references.
- Rebuild so only one command produces the output.
Avoid overlapping folder and file references
Do not add both a folder reference and individual files it contains; pick one so each output is produced once.
# In Build Phases > Copy Bundle Resources, ensure each
# resource appears exactly once across the target.How to prevent it
- Keep each resource referenced once across the target's phases.
- Avoid mixing folder references with the individual files inside them.
- Review project file diffs for duplicate resource entries before merging.