Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 877
Faisal Manzer Avatar asked Nov 23 '19 12:11

Faisal Manzer


Video Answer


3 Answers

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
like image 110
Hillkim Henry Avatar answered Oct 13 '22 01:10

Hillkim Henry


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

like image 30
Mr Talha Avatar answered Oct 13 '22 01:10

Mr Talha


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.

like image 6
Amir-Mousavi Avatar answered Oct 13 '22 00:10

Amir-Mousavi