Xcode 10 Error Multiple commands produce
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
XCode is Apple's integrated development environment (IDE) used primarily for developing software for macOS, iOS, watchOS, and tvOS. One common issue that developers encounter when using Xcode, particularly from version 10 onwards, involves build errors deemed as "Multiple commands produce". This error typically causes confusion and frustration as it often interrupts the build process, sometimes without clear indications of what is wrong.
Understanding the "Multiple Commands Produce" Error
The "Multiple commands produce" error occurs when the Xcode build system detects that multiple outputs have been produced for the same build artifact or target file during a build operation. This is usually the result of project misconfiguration. The new build system introduced in Xcode 10 and enhanced in later versions utilizes a more robust dependency management strategy, which strictly ensures that no two targets produce the same output file.
Technical Explanation:
Under the new build system, Xcode uses a Directed Acyclic Graph (DAG) to manage build dependencies. If Xcode's build graph determines multiple paths produce the same output artifact, it will throw the “Multiple commands produce” error. For example, consider the scenario where two different script phases or target dependencies in a project create the same output file, like an app extension or a bundled resource.
Examples:
- Copied Files in Build Phases:
- If two different script phases copy the same resource file to the output directory, this error would occur.
- Overlapping Output Files:
- If one target generates a file named
output.logand another target in the same workspace also generates a file with the same name in the same output directory.
General Causes:
- Two targets generating the same output file.
- Copy resources build phases that list the same file.
- Incorrect custom scripts copying files to the same location.
How to Resolve the Error
The solution generally involves identifying and correcting the conflicting build settings or scripts. Here are some steps and guidance to help with resolving this issue:
- Check Build Phases for Duplicate Outputs:
- Navigate to the target's build phases in Xcode and examine each phase to ensure no files are duplicated across different phases.
- Examine Custom Scripts:
- Review any custom shell script build phases that may output to a common location and adjust them accordingly.
- Use Unique Bundle Identifiers:
- Ensure that different targets (e.g., app and app extensions) have unique bundle identifiers.
- Clean and Rebuild the Project:
- Sometimes, simply cleaning the build folder (
Product>Clean Build Folder) and rebuilding the project can resolve these types of errors.
- Disable the New Build System Temporarily:
- As a last resort, switch back to the legacy build system to see if the problem persists. Navigate to
File->Project/Workspace Settingsand then change the build system under the shared workspace settings.
Additional Tips
- Always validate changes in version control systems before committing, as sometimes reverting some recent changes can solve the problem.
- Regularly update Xcode to ensure compatibility and efficiency with the latest tools and features.
Summary Table
| Issue Component | Common Cause | Suggested Solution |
| Resources files | Duplicate files in "Copy Bundle Resources" | Ensure unique file management in build settings |
| Script Output | Conflicting output from custom scripts | Modify script or output destination |
| Build Artifacts | Overlapping output from different build targets | Configure separate output paths for each target |
| Legacy vs. New Build System | Incompatibility or bugs in the build system | Optionally revert to legacy build system for a test |
Conclusion
Resolving the "Multiple commands produce" error in Xcode involves careful review and management of build phases and dependencies. By understanding the intricacies of build settings and maintaining organized and unique configurations, developers can mitigate these issues and enhance their development workflow. Always keep an open mind to updating Xcode to leverage improvements in the build system that may inherently resolve such complications.
Related reading
- Xcode 10b5 - duplicate symbol linker error, can''t compile with Crashlytics
- Xcode 11 backward compatibility UIWindowScene is only available in iOS 13 or newer
- Xcode 11 debugger is extremely slow - A known problem?
- Xcode 12.3 Building for iOS Simulator, but the linked and embedded framework was built for iOS iOS Simulator
- Xcode 14.3 build error unable to initiate PIF transfer session operation in progress?
- Xcode 15 Unable to boot the Simulator
- Xcode 12.4 “Unsupported OS version” after iPhone iOS update 14.7
- Xcode 13.3 beta 3 swift package init shows warning /Library/org.swift.swiftpm/collections.json has been deprecated but dunno how to use new one
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.