Build Failing for React Native iOS, "Multiple commands produce" Error

13,054

Solution 1

The problem is you have duplicate resources due to RN auto-linking. To fix this

  1. Click Your Xcode project Name on project files
  2. Navigate to Build Phases tab
  3. Scroll down to Copy Bundle Resources drop down to expand
  4. Scroll down to Copy Pod Resources and compare the duplicates with the ones on Copy Bundle Resources
  5. Delete the duplicates on Copy Bundle Resources not on Copy Pod Resources
  6. Rebuild your project. Also refer to this issue

Solution 2

The problem seems to be caused by the new autolinking feature in React Native 0.60 - the line use_native_modules! in ios/Podfile means when you do pod install, any pods found in node_modules are automatically linked. This means that links to all font files are added to [CP] Copy Pods Resources when you do pod install.

Please see this image.

  1. Open Your iOS project in Xcode.

  2. Then follow these steps in the image.

    enter image description here

  1. You will see input Files and output files under Copy Pod Resource. Remove the duplicate ones listed here from the above list in Copy Bundle Resources.

  2. Run react-native run-ios

Solution 3

You need to delete this manually from Copy Bundle resource.

Else You need to change build setting to build using legacy build.

You will find the Copy Bundle resource under build phases.

enter image description here

Solution 4

For the xCode 11+ and react-native 0.60+,

The answer is copied from this GitHub issue answer

The problem seems to be caused by the new autolinking feature in React Native 0.60 - the line use_native_modules! in ios/Podfile means when you do pod install, any pods found in node_modules are automatically linked. This means that links to all font files are added to [CP] Copy Pods Resources when you do pod install.

If you previously installed react-native-vector-icons manually by adding the font files to Copy Bundle Resources, you then get a "Multiple commands produce..." fatal build error.

So to fix the problem, just remove the font files from Copy Bundle Resources, so that they are only in [CP] Copy Pods Resources.

So the official documentation on the repository of the library is outdated and does not mention it. You should follow installation steps up to adding the fonts list to info.plist, and DO NOT create Fonts folder-group and copy-paste the fonts into that folder.

Solution 5

I am able to solve the issue by following this step. All you have to do is open your project folder -> go to /ios and open file YourProjectName.xcodeproj then follow this https://lifesaver.codes/answer/error-multiple-commands-produce-in-xcode-10, then you just need to delete all fonts there and run npx react-native run-ios

Share:
13,054
Faisal Manzer
Author by

Faisal Manzer

Having a dream to create new technologies. Currently working with web development and app development. Successfully hosted web apps to the cloud and submitted mobile applications to Google PlayStore and Apple AppStore. Designing basic UI with the sketch app. Worked with digital marketing experts and created tools for them.

Updated on June 10, 2022

Comments

  • Faisal Manzer
    Faisal Manzer almost 2 years

    We were working on a react native project. One of my team members added some native modules on Linux and linked android. By then I am trying to link things in iOS but the build is always failing with this kind of error trace. The Android project is building normally.

    I deleted xyz.xcworkspace and Podfile.lock then tried pod install.
    Also, I tried to delete my node_modules and then yarn install followed by yarn link.

    react-native-cli: 2.0.1  
    react-native: 0.61.4  
    yarn 1.19.1
    Pod 1.8.4
    XCode Version 11.2.1 (11B500)
    macOS Catalina 10.15.1 (19B88)
    

    xyz warning

    duplicate output file '/Users/user/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Products/Debug-iphonesimulator/xyz.app/AntDesign.ttf' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/faisal/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Intermediates.noindex/xyz.build/Debug-iphonesimulator/xyz.build/Script-47F818C57EEC47EA3303EA1B.sh
    

    xyz workspace errors

    Multiple commands produce '/Users/user/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Products/Debug-iphonesimulator/xyz.app/Zocial.ttf':
    1) Target 'xyz' (project 'xyz') has copy command from '/Users/user/Desktop/xyz/native/node_modules/react-native-vector-icons/Fonts/Zocial.ttf' to '/Users/user/Library/Developer/Xcode/DerivedData/xyz-hhesslamjsqmbobykhskliclusph/Build/Products/Debug-iphonesimulator/xyz.app/Zocial.ttf'
    2) That command depends on command in Target 'xyz' (project 'xyz'): script phase “[CP] Copy Pods Resources”
    

    There are multiple errors and warnings like this but have same format with different file names.