React-native: 'Multiple commands produce' error when building with new Xcode build system

Created on 1 Aug 2018  ยท  69Comments  ยท  Source: facebook/react-native

Hello,

Environment:

React Native Environment Info:
    System OS: macOS High Sierra 10.13.6
    Binaries:
      Node: 8.11.3 - /usr/local/bin/node
      npm: 5.6.0 - /usr/local/bin/npm
    IDEs:
      Xcode: 10 Beta 3
    npmPackages:
      react: 16.4.1
      react-native: 0.56.0

Error:

I got the following error when I try to build the simple RN 0.56 application:

warning: Skipping duplicate build file in Compile Sources build phase: <PATH_TO_PROJECT>/node_modules/react-native/React/Modules/RCTRedBoxExtraDataViewController.m (in target 'React-tvOS')
...
warning: duplicate output file '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTResizeMode.h' on task: PBXCp <PATH_TO_PROJECT>/node_modules/react-native/Libraries/Image/RCTResizeMode.h <HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTResizeMode.h (in target 'React')
...
error: Multiple commands produce '<PbxCp <HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTScrollableProtocol.h>':
1) Target 'React-tvOS' has copy command from '<PATH_TO_PROJECT>/node_modules/react-native/React/Views/ScrollView/RCTScrollableProtocol.h' to '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTScrollableProtocol.h'
2) Target 'React' has copy command from '<PATH_TO_PROJECT>/node_modules/react-native/React/Views/ScrollView/RCTScrollableProtocol.h' to '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTScrollableProtocol.h'
error: Multiple commands produce '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/double-conversion/fast-dtoa.h':
1) Target 'double-conversion-tvOS' has copy command from '<PATH_TO_PROJECT>/node_modules/react-native/third-party/double-conversion-1.1.5/src/fast-dtoa.h' to '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/double-conversion/fast-dtoa.h'
2) Target 'double-conversion' has copy command from '<PATH_TO_PROJECT>/node_modules/react-native/third-party/double-conversion-1.1.5/src/fast-dtoa.h' to '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/double-conversion/fast-dtoa.h'
...

Repro steps:

  • react-native init
  • xcodebuild -project <PATH_TO_PROJECT>/ios/ReactNativeSimple.xcodeproj -scheme ReactNativeSimple archive -sdk iphoneos -archivePath <PATH_TO_PROJECT>/output/build/archive/ReactNativeSimple CODE_SIGN_STYLE=Automatic

Details:

I tested it on the simple RN application that was created by "react-native init" command.
When I try to build the app using Xcode 10 GUI - it builds successfully.
But I try to build it using xcodebuild command - it failed with the error above.

When we use the same command on the same application (RN 0.56) in Xcode 9.4.1 - it builds successfully
If I don't specify -sdk param in xcodebuild command it builds successfully.
Note: _Errors may be different for the different Xcode 10 Beta versions._

Questions:

Does RN 0.56 support Xcode 10 Beta?
How I can fix it?
Is there workaround to build it using Xcode 10 Beta?

Bug iOS Locked

Most helpful comment

You can try to change the build system to Legacy,
File > Workspace Settings > Build System > Legacy Build System.

All 69 comments

You can try to change the build system to Legacy,
File > Workspace Settings > Build System > Legacy Build System.

We want to use new build system.

The new build system should be supported. We're tracking any issues people run into with Xcode 10 or the new build system in this task: https://github.com/facebook/react-native/issues/19573

At a glance, it does not seem like your issue is covered by what we've fixed so far on master. I'll add it to the list.

I also had the Multiple commands produce error with libReact.a & libyoga.a.
I'm using:

  • Xcode 10
  • react-native 0.57.0
  • CocoaPods

To overcome this, I have added this to my Podfile:

  post_install do |installer|
    installer.pods_project.targets.each do |target|

      # The following is needed to ensure the "archive" step works in XCode.
      # It removes React & Yoga from the Pods project, as it is already included in the main project.
      # Without this, you'd see errors when you archive like:
      # "Multiple commands produce ... libReact.a"
      # "Multiple commands produce ... libyoga.a"

      targets_to_ignore = %w(React yoga)

      if targets_to_ignore.include? target.name
        target.remove_from_project
      end

    end
  end

Then rebuild your Pods project with:

$ pod install

Full environment details:


  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 4.10 GB / 32.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.9.0 - ~/.nvm/versions/node/v10.9.0/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.9.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
    IDEs:
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0
      react-native: 0.57.0 => 0.57.0
    npmGlobalPackages:
      create-react-native-app: 1.0.0
      react-native-cli: 2.0.1

Confirmed @PaulMest's workaround works. Manually deleting Yoga in Xcode, from the Pods project's Targets should work too, as I've been doing with React which has been causing duplicate targets build errors as well, before RN 0.57.

If you are using xcodebuild, append this -UseModernBuildSystem=NO to opt into the old legacy build system

@PaulMest Thanks, I've made my day

Hopefully my situation can help you guys fix the issue!

Here is the full output:

:-1: Multiple commands produce '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Roboto.ttf':
1) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/native-base/Fonts/Roboto.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Roboto.ttf'
2) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/src/Resources/Fonts/Roboto.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Roboto.ttf'

:-1: Multiple commands produce '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Zocial.ttf':
1) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/native-base/Fonts/Zocial.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Zocial.ttf'
2) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/react-native-vector-icons/Fonts/Zocial.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Zocial.ttf'

:-1: Multiple commands produce '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Ionicons.ttf':
1) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/native-base/Fonts/Ionicons.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Ionicons.ttf'
2) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/react-native-vector-icons/Fonts/Ionicons.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Ionicons.ttf'

Essentially, react-native-vector-icons and native-base both bundle the same font files. (And for some reason we also have one of them bundled ourselves; I'll be sure to remove that one.) Before updating to Xcode 10 / Mojave, there was no issue. The only change was to update from Xcode 9 to Xcode 10.

@ntomallen I've ran into the exact same issue with duplicate fonts from react-native-vector-icons and native-base and what I ended up doing was removing the duplicate from my target app's Copy Resources To Bundle section. After this, my project worked again (well, it moved to two different errors, which are described here: libfishhook.a can not be found - fix and Multiple commands produce error with libReact.a & libyoga.a. - fix

So far, my app has been running fine & I can compile using XCode 10's new build system.

_Disclaimer: I am not an experienced iOS developer and hacked these solutions together. I do not know if I have messed something up I don't know about._

That's exactly what worked for me as well! Though I'm still curious why it is suddenly an error now but not previously.
On Sep 26, 2018, 2:49 PM -0400, Niels Bokmans notifications@github.com, wrote:

@ntomallen I've ran into the exact same issue with duplicate fonts from react-native-vector-icons and native-base and what I ended up doing was removing the duplicate from my target app's Copy Resources To Bundle section. After this, my project worked again (well, it moved to two different errors, which are described here: libfishhook.a can not be found - fix and Multiple commands produce error with libReact.a & libyoga.a. - fix
So far, my app has been running fine & I can compile using XCode 10's new build system.
Disclaimer: I am not an experienced iOS developer and hacked these solutions together. I do not know if I have messed something up I don't know about.
โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@ntomallen Basically it's because there is a new, "stricter" build system, and XCode 10 uses it by default whereas in XCode 9 you had to actively choose to use it rather than the "legacy" build system which we've all been using until now.

Ok. This is maddening. I switched to the legacy build system. Now, I get a different error.

/Users/michaelstelly/Documents/projects/mobile_gtm/node_modules/react-native/React/../third-party/glog-0.3.4/src/base/mutex.h:105:10: fatal error: 'config.h' file not found
#include "config.h"           // to figure out pthreads support

I have no idea what this means, other than the obvious - a file is missing. But before Xcode 10, I had no build problems whatsoever.

@mjstelly are you on 0.57? Your error message mentions glog-0.3.4 but 0.57 uses glog-0.3.5. I just want to make sure we're tracking issues on the latest release.

@PaulMest my hero! Thank you!

Hello @mjstelly

Are you facing the similar issue of with third-party.....
i'm using xcode 10

  1. In file included from /Users/ehs-mobile-app/node_modules/react-native/third-party/folly-2016.09.26.00/folly/json.cpp:17

Xcode 10.1 Seems to be building fine on both systems but I can't archive on either, many build errors. What to do now?

You have to be more specific. Xcode 10 builds and archives fine for me (after solving some errors I don't remember now), on MacOS 10.12.6 and RN 0.57.0.

My Podfile post_install looked like this:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
    if target.name == 'yoga'
      target.remove_from_project
      target.build_configurations.each do |config|
          config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO'
          config.build_settings['GCC_WARN_64_TO_32_BIT_CONVERSION'] = 'NO'
      end
    end
  end
end

Following the suggestion from @PaulMest worked for me.

@njbmartin Thanks!
only your fix worked for me

-UseModernBuildSystem=NO

This works for me. Man it took me too long to find this. Thanks.

Switching to the legacy build system fixes a lot of build errors but we really need to be able to use the modern system into the future :p

Also, Happy Thanksgiving to those of you celebrating!

yes, the new version is of course nice but it is not so smooth.
Upgrade with risk.

@PaulMest Thank you. Your hack works :)

Confirmed @PaulMest's workaround works. Manually deleting Yoga in Xcode, from the Pods project's Targets should work too, as I've been doing with React which has been causing duplicate targets build errors as well, before RN 0.57.

How to do this exactly @fungilation ?

This is the only known blocker left in #19573. Are folks still running into this problem in 0.57.8?

I have no issue generally with Xcode since 0.57.8

@hramos Unfortunately not. For me the Xcode legacy build option is still required with 0.57.8 and also with the new 0.58.0-rc.3 (edit: also with 0.58.3).

To make this reproducible, I create a fresh new project and test it locally and with travis CI. I linked the original project below (but its just created with react-native init) and the successful and broken builds on travis. Maybe this helps? At least I could and will re-run this experiment when there is a new version available.

@hramos I am running into it when I run a build with detox, not yarn ios. Here is my config for my iOS simulator:

{
    "configurations": {
        "ios.sim.debug": {
            "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/reactipay.app",
            "build": "xcodebuild -project ios/reactipay.xcodeproj -scheme reactipay -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
            "type": "ios.simulator",
            "name": "iPhone 6"
        },
        "android.emu.debug": {
            "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
            "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
            "type": "android.emulator",
            "name": "emulator-5554"
        }
    },
    "test-runner": "jest"
}

Specifically, if I run this: xcodebuild -project ios/reactipay.xcodeproj -scheme reactipay -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build it fails with the original error.

I also had the Multiple commands produce error with libReact.a & libyoga.a.
I'm using:

  • Xcode 10
  • react-native 0.57.0
  • CocoaPods

To overcome this, I have added this to my Podfile:

  post_install do |installer|
    installer.pods_project.targets.each do |target|

      # The following is needed to ensure the "archive" step works in XCode.
      # It removes React & Yoga from the Pods project, as it is already included in the main project.
      # Without this, you'd see errors when you archive like:
      # "Multiple commands produce ... libReact.a"
      # "Multiple commands produce ... libyoga.a"

      targets_to_ignore = %w(React yoga)

      if targets_to_ignore.include? target.name
        target.remove_from_project
      end

    end
  end

Then rebuild your Pods project with:

$ pod install

Full environment details:

thnx man!

I very confused with this error as it doesn't seem consistent. if I run build command 10 time, it could eventually start working
this is how looks mu e2e script

detox build -c ios.sim.releas ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release

where is detox build is

xcodebuild -project ios/deliverypoc.xcodeproj -scheme deliverypoc -configuration Release -sdk iphonesimulator -derivedDataPath ios/build

I can't use legacy build system as it hangs on react build, and I don't use Cocoa Pods.
What other solutions could be?
Shall I migrate my iOS to Cocoa? What implications it would bring?

@pavlof01 I am specifically looking for reports of this still occurring on versions 0.57.8 or newer.

@hramos I still have this on Xcode 10.1 on 0.57.8 and 0.58.3. I haven't tried to run using the legacy build system (is that the official fix for now?)--instead, I am using the Podfile to target.remove_from_project when name == "React" or name == "yoga". I also haven't tried Xcode 9, etc, as @jerolimov has above.

This is not a blocking issue for us, but just though I'd chime in! Lmk if I can provide any more helpful info.

Note that when I said I have no issue anymore on RN 0.57.8, I'm also using this workaround in Podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|

    targets_to_ignore = %w(React yoga)

    if targets_to_ignore.include? target.name
      target.remove_from_project
    end

  end
end

Forgot about it ๐Ÿ˜›

@hramos I am using 0.57.8 (same error) - let me know if you need any additional info.

I ran into this as well with detox. I fixed it by specifying a destination in xcodebuild instead of the sdk: -destination 'platform=iOS Simulator,name=iPhone 7'

Can confirm it occurs on 0.58.3 during the archive step. Adding the remove_from_project workaround to my podfile resolves it. Output of react-native info:

$ $(npm bin)/react-native info

  React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
      Memory: 1.13 GB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.0.0 - /usr/local/bin/node
      Yarn: 1.10.1 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 19, 21, 22, 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.3, 27.0.3, 28.0.1, 28.0.2, 28.0.3
        System Images: android-19 | Google APIs Intel x86 Atom, android-21 | Google APIs Intel x86 Atom_64, android-22 | Google APIs Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom_64, android-25 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom_64
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmGlobalPackages:
      react-native-cli: 2.0.1

Thanks @aaronjensen struggled many hours on this one...

I've been using the new build system since 58 with no issues.

I did have Multiple commands produce * issues like the above but this was due to leftovers from before I switched to Pods (linking); make sure you remove all React Native related Linked Frameworks and Libraries from your Xcode project (not the generated workspace) if you're now using Pods.

After you've cleaned it up and switched to using RN via Pods it should look something like this:

image

And NOT like this:
image

Note that the old build system ignored these duplications from trying to use RN via linking & pods together; the new build system does not; so you may have had these for some time.

If you're building with xcodebuild e.g. for Detox make sure to apply @aaronjensen 's suggestion from above to your build command.

@salakar Ive been doing the same with no issues. One thing to note is that if you manually linked a 3rd party Libray without pods, it may have trouble finding React Native. Basically try to switch everything to Pods.

Closing as per @Salakar's comment.

@cpojer IMHO this isn't solved if the solution requires manual steps after creating a simple project with react-native init. This is not what new users will expect. The default should just work without any changes in Xcode and without CocoaPods. (Although CocoaPods is great and works fine with RN ๐Ÿ˜)

As explained before, I created a sample app with react-native init and run this on Travis CI. This shows well that the build works fine with Xcode 9 and Xcode 10 with the legacy build system. And it doesn't work with the Xcode 10 new build system.

You can see the build history here on GitHub, the master is already 0.59.0-rc.1 and has still the same problem.

The build history for different branches is available on Travis CI (master is Xcode 9 and there are two branches for Xcode 10) and as GitHub Pull Request

As said. IMHO. ๐Ÿ˜

@jerolimov your build is not specifying a destination, which appears to be essential as it otherwise attempts to build artifacts for both tvOS and iOS, which causes the issue you're seeing.

What isn't clear is if there's something that RN can be doing that could cause the new build system to know which you want implicitly or if this is actually just a bug in xcode (in which case this is the wrong repo for the issue).

Given @Salakar's comment

It appears I did not clean up linked frameworks and libraries correctly when I switched to start using Pods. Can anyone provide more detail on the correct process go about removing those links?

In Xcode, right click all of the things which reference React Native(usually under Frameworks or Libraries in the sidebar), and choose to "remove references". At the end of the process, make sure the Linked Libraries and Frameworks section doesn't have references to React Native. Note that as you do this, your other 3rd party libraries which depend on React Native should be linked through Pods as well. (Most of the major ones support it, which is nice.)

I ran into this as well with detox. I fixed it by specifying a destination in xcodebuild instead of the sdk: -destination 'platform=iOS Simulator,name=iPhone 7'

@aaronjensen Can you please provide the full code as a sample?

"xcodebuild -project ios/AppName.xcodeproj -scheme AppName -configuration Debug -derivedDataPath ios/build -destination 'platform=iOS Simulator, name=iPhone 7'" ?

Sure, what you have looks pretty much like what we're using.

xcodebuild -project ios/AppName.xcodeproj -scheme AppName -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 7' -derivedDataPath ios/build

I also had the Multiple commands produce error with libReact.a & libyoga.a.
I'm using:

  • Xcode 10
  • react-native 0.57.0
  • CocoaPods

To overcome this, I have added this to my Podfile:

  post_install do |installer|
    installer.pods_project.targets.each do |target|

      # The following is needed to ensure the "archive" step works in XCode.
      # It removes React & Yoga from the Pods project, as it is already included in the main project.
      # Without this, you'd see errors when you archive like:
      # "Multiple commands produce ... libReact.a"
      # "Multiple commands produce ... libyoga.a"

      targets_to_ignore = %w(React yoga)

      if targets_to_ignore.include? target.name
        target.remove_from_project
      end

    end
  end

Then rebuild your Pods project with:

$ pod install

Full environment details:


  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 4.10 GB / 32.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.9.0 - ~/.nvm/versions/node/v10.9.0/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.9.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
    IDEs:
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0
      react-native: 0.57.0 => 0.57.0
    npmGlobalPackages:
      create-react-native-app: 1.0.0
      react-native-cli: 2.0.1

great work
rm -rf Pods; pod install worked for me

@Salakar Removing all the RCT* libraries from the Linked Frameworks and Libraries in Xcode project builds successfully in iOS but gives the Native module cannot be null error. And only after i add the libReact.a and other libRCT*.a libraries the build works. We are using Pods to manage other dependencies.

Below is how our Podfile looks,

```source 'https://github.com/CocoaPods/Specs.git'

Global platform for your project

platform :ios, '9.0'

Ingore all the warnings from the CocoaPods libraries.

inhibit_all_warnings!
plugin 'cocoapods-fix-react-native'

target 'RNMobile' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!

# Basic Pods for RNMobile
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'CxxBridge',
'DevSupport',
# the following ones are the ones taken from "Libraries" in Xcode:
'RCTAnimation',
'RCTActionSheet',
'RCTBlob',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket'
]

# the following dependencies are dependencies of React native itself.
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/GLog.podspec'

# Extra pods for WahedMobile
pod 'AppCenter/Crashes', '~> 1.13.0'
pod 'AppCenter/Analytics', '~> 1.13.0'
pod 'AppCenterReactNativeShared', '~> 1.12.0'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
pod 'lottie-ios', :path => '../node_modules/lottie-ios'
pod 'RNAWSCognito', :path => '../node_modules/amazon-cognito-identity-js'
pod 'TouchID', :path => '../node_modules/react-native-touch-id'
pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
pod 'RNSVG', :path => '../node_modules/react-native-svg'
pod 'react-native-camera', :path => '../node_modules/react-native-camera'

pod 'CodePush', :path => '../node_modules/react-native-code-push'

pod 'RNAnalytics', :path => '../node_modules/@segment/analytics-react-native'

# Firebase Libs
pod 'Firebase/Core', '~> 5.15.0'
pod 'Firebase/Messaging', '~> 5.15.0'

# Onfido Libs
pod 'Onfido', '10.3.0', :configurations => ['Debug']
pod 'Onfido-Release', '10.3.0', :configurations => ['Release']

pod 'RNKeychain', :path => '../node_modules/react-native-keychain'

end
```

Also adding the libs in the Linked Frameworks and Libraries creates duplicate symbols errors in AppCenter.

For reference for react native users that are upgrading to 59 and have pods:
On top of @anandwahed 's solution above, I ended up 1- analyze project in XCode and 2- manually remove every target that has tvOS on it.

My Podfile post_install looked like this:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
    if target.name == 'yoga'
      target.remove_from_project
      target.build_configurations.each do |config|
          config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO'
          config.build_settings['GCC_WARN_64_TO_32_BIT_CONVERSION'] = 'NO'
      end
    end
  end
end

Following the suggestion from @PaulMest worked for me.

your solution worked for me, tanks.

https://github.com/facebook/react-native/issues/20492#issuecomment-464343895

That and killing a stale instance of the metro packager helped me.

I am having this issue and I am not using cocoapods. Can't use cocoapods as I am using react-native-navigation.

@MakhouT using react-native-navigation doesn't restrict you from using cocoapods

@AngefloMusic React-native-navigation isn't using it and for the setup you need to change some native iOS files. When using cocoapods, I am assuming this will be conflicting with each other when installing pod dependencies. However I am not sure as I haven't cocoapoads too much. So please do correct me if I am wrong.

@MakhouT They do not conflict. In fact, if you have a look at the react-native-navigation repo you'll see there is a podspec file. I'm using RNN with cocoapods in a project now.

Sorry I need to reopen this, but the most preferred solution (see Podfile below) brings me to this painful error when trying to produce the archive.

immagine

this is my podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '10.1'

target 'TVTips' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  #use_frameworks!

  # Pods for TVTips
  pod 'Firebase/Core', '~> 5.20.1'
  pod 'Firebase/Analytics', '~> 5.20.1'
  pod 'Firebase/Auth'
  pod 'GoogleSignIn', '~> 4.4.0'
  pod 'TwitterKit', '~> 3.3.0'
  pod 'React', :path => '../node_modules/react-native', :modular_headers => true
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'react-native-twitter-signin', :path => '../node_modules/react-native-twitter-signin'

  target 'TVTips-tvOSTests' do
    inherit! :search_paths
    # Pods for testing

    pod 'YouTubeSdk', :path => '../node_modules/react-native-youtube-sdk'

    pod 'ReactNativeLocalization', :path => '../node_modules/react-native-localization'

    pod 'RNShare', :path => '../node_modules/react-native-share'

  end

  target 'TVTipsTests' do
    inherit! :search_paths
    # Pods for testing
  end

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end

      targets_to_ignore = %w(React yoga)

      if targets_to_ignore.include? target.name
        target.remove_from_project
      end

    end
  end

end

I have React imported both in Link Binary with libraries and in Linked Frameworks and libraries.
Help :)

For me work removing duplicated resources in inside

Build Phases
As example bellow, Fonts was making an error

image

I know this is a solved problem for people who moved RN to Pods or people who use RN > 0.60.x but if you aren't ready yet or migrating this is our temporary solution (It basically removed tvOS config from React Native pbxproj file, which seems to be causing the multiple targets).

We use it in our postinstall script

const xcode = require('xcode');
const fs = require('fs');
const path = require('path');

const reactNativeProjectPath = path.resolve(__dirname, '../node_modules/react-native/React/React.xcodeproj/project.pbxproj');
const myProj = xcode.project(reactNativeProjectPath);

myProj.parse(err => {
    if (err) {
        throw err;
    }

    const nativeTargets = myProj.hash.project.objects.PBXNativeTarget;

    Object.keys(nativeTargets).forEach(nativeTargetKey => {
        const target = nativeTargets[nativeTargetKey];
        if (target.name && target.name.indexOf('-tvOS') !== -1) {
            console.log(`Removing ${target.name}:${nativeTargetKey} in React pbxproj`);
            delete nativeTargets[nativeTargetKey];
        }
    });

    fs.writeFileSync(reactNativeProjectPath, myProj.writeSync());
    console.log(`All mentioned of tvOS removed in React pbxproj`);
});

For those who use Fastlane and face this issue, @PaulMest solution works: add all required targets to targets_to_ignore and then run rm -rf ios/Pods && pod install before running Fastlane

For me work removing duplicated resources in inside

Build Phases
As example bellow, Fonts was making an error

image

Adding to @aerda's answer, I removed all of the fonts (.tff files) used by react-native-vector-icons from Build Phases > Copy Bundle Resources and my project is now building.

I believe this error in my case was related to updating to XCode 11, but am not positive about that last part.

I confirm the same with fonts being duplicate, only after upgrade to Xcode 11 stable today (Mac 10.14.6). Removing fonts under the [CP] Copy Pods Resources section of Xcode's Build Phases and build works again.

Was and is using New build system. On RN 0.60.5.

@fungilation the same with me (Xcode 11 - upgraded today, new build system and RN 0.60.5). I have to removed all font under Copy Bundle Resources and it works.

But when I execute pod install command next time, this entries will appear again ๐Ÿ˜‚๏ธ

same here with 0.61.0-rc.3 and xcode 11 11A420a mojave 10.14.6

I have only removed react-native-vector-icons tff and it works. No need to delete all tffs

delete previous pods install pod then run update pod it will work.

this is what I added to my podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end

    if target.name == "yoga"
      target.remove_from_project
    end
  end

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf'
    end
  end
end

this is what I added to my podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end

    if target.name == "yoga"
      target.remove_from_project
    end
  end

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf'
    end
  end
end

I tried this command (with fastlane) but even then the errors persist. ๐Ÿ˜ข

error: Multiple commands produce '.../UninstalledProducts/iphoneos/libRNGestureHandler.a':

I get similar errors for 4 other libraries that I have installed -
RNKeyChain, RNAsyncStorage, RNDeviceInfo and BVLinearGradient

Here's my environment -

System:
    OS: macOS 10.15.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 1.54 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.10.0 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 26, 27, 28, 29
      Build Tools: 27.0.3, 28.0.3, 29.0.1
      System Images: android-19 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.2/11B52 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: ^0.60.5 => 0.60.5 
  npmGlobalPackages:
    react-native-cli: 2.0.1

Been trying to find a solution since morning, have found nothing working so far. ๐Ÿ‘Ž
Even though when I run in an emulator, it works just fine.

I confirm the same with fonts being duplicate, only after upgrade to Xcode 11 stable today (Mac 10.14.6). Removing fonts under the [CP] Copy Pods Resources section of Xcode's Build Phases and build works again.

Was and is using New build system. On RN 0.60.5.

For newbies like me: you need to edit the file <PROJECT_FOLDER>/ios/<PROJECT_NAME>.xcodeproj/project.pbxproj

Then comment out the font lines (files ending in .ttf) like this:

inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-drawer2/Pods-drawer2-resources.sh", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/AntDesign.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Entypo.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Feather.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome5_Brands.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome5_Regular.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome5_Solid.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Fontisto.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Foundation.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Octicons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Zocial.ttf", ); name = "[CP] Copy Pods Resources"; outputPaths = ( // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AntDesign.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Entypo.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/EvilIcons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Feather.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome5_Brands.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome5_Regular.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome5_Solid.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Fontisto.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Foundation.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Ionicons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MaterialCommunityIcons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MaterialIcons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Octicons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SimpleLineIcons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Zocial.ttf", );

And I had to redo this process every time I ran pod install

Was this page helpful?
0 / 5 - 0 ratings

Related issues

janmonschke picture janmonschke  ยท  3Comments

WG-Com picture WG-Com  ยท  3Comments

phongyewtong picture phongyewtong  ยท  3Comments

aniss picture aniss  ยท  3Comments

axelg12 picture axelg12  ยท  3Comments