32

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.

Faisal Manzer
  • 2,089
  • 3
  • 14
  • 34

6 Answers6

63

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
Hillkim Henry
  • 2,841
  • 13
  • 17
24

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

karel
  • 5,489
  • 46
  • 45
  • 50
Mr Talha
  • 705
  • 7
  • 13
10

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.

Amir-Mousavi
  • 4,273
  • 12
  • 70
  • 123
6

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

Manav
  • 2,284
  • 1
  • 14
  • 27
0

What fixed it for me was removing multiple entries of [CP] Embed Pods Frameworks / and / [CP] Copy Pods Resources */, within a single buildPhases block in the project.pbxproj file. These got added while upgrading RN version to 0.68.7.

For instance:

buildPhases = (
            ...
            00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */,
            E235C05ADACE081382539298 /* [CP] Embed Pods Frameworks */, <== newly added
            ...
    );

Removing the older entry (00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks*/, in this case) and also the corresponding block of code from /* Begin PBXShellScriptBuildPhase section */

00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
            isa = PBXShellScriptBuildPhase;
            buildActionMask = 12;
            files = (
            );
            inputFileListPaths = (
                ...
            );
            name = "[CP] Embed Pods Frameworks";
            outputFileListPaths = (
                ...
            );
            ...
        };

made the error go away.

sj_959
  • 175
  • 5
  • 12
-1

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

Ajeng
  • 39
  • 1
  • 6