11

I get an error when I try to archive my react native app using release configurations in Xcode - Target 'yoga' (libyoga.a)

error: Multiple commands produce '/Users/mat/Library/Developer/Xcode/DerivedData/ListadoV1-ghytgthpajfllcakinpdoknnalbr/Build/Intermediates.noindex/ArchiveIntermediates/ListadoV1/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libyoga.a':
1) Target 'yoga' has a command with output '/Users/mat/Library/Developer/Xcode/DerivedData/ListadoV1-ghytgthpajfllcakinpdoknnalbr/Build/Intermediates.noindex/ArchiveIntermediates/ListadoV1/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libyoga.a'
2) Target 'yoga' has a command with output '/Users/mat/Library/Developer/Xcode/DerivedData/ListadoV1-ghytgthpajfllcakinpdoknnalbr/Build/Intermediates.noindex/ArchiveIntermediates/ListadoV1/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/libyoga.a'

How to resolve this in the new build system?

Matheswaaran
  • 145
  • 2
  • 11

1 Answers1

15

[Update 20190926: If you upgrdae react-native 0.60+, which is cocoapods native, this sort of thing should never happen and the workaround I posted below should not be necessary]


If I may make some assumptions, you are using react-native (libyoga is referenced), you are using the new build system from XCode 10+ (not the legacy system) and you have integrated CocoaPods (likely to use Firebase or similar).

Please correct me if I am wrong, but that's my setup, and that's what produced this error for me.

You have three options in increasing order of effort and correctness.

First, you can get moving this moment with no effort by just ignoring/hiding the problem by switching your build to the Legacy Build System[1]:

1. In Xcode, go to File->Project/Workspace settings.
2. Change the build system to Legacy Build system.

Second, you can get moving with the new XCode build system with a little effort if you add a workaround snippet[2] in your Podfile until the problem is fixed upstream in react-native or Cocoapods. I am doing this now and my project successfully archives:

 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 as @jules-randolph points out - you must run a pod install in your iOS folder to start using the Podfile changes you made)

Third, you can do the work to completely convert your project to Pods by removing any left over references to react-native frameworks in your project (as opposed to the workspace configred by Pods).[3]. I have not done this yet but it is the correct thing to do and closed the upstream issue.

References, and note the parent issue in general is useful

[1] https://github.com/facebook/react-native/issues/20492#issuecomment-422958184

[2] https://github.com/facebook/react-native/issues/20492#issuecomment-409599358

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

Mike Hardy
  • 2,274
  • 3
  • 25
  • 57
  • @Matheswaaran have you examined this? I am curious if my answer suits you – Mike Hardy Mar 27 '19 at 14:36
  • 2
    You forgot to mention to run `pod install` from `ios` folder after editing Podfile! – Jules Sam. Randolph Mar 29 '19 at 16:16
  • Thanks @JulesRandolph you are right and that's a step that's easy to forget if you are new to CocoaPods (like myself) – Mike Hardy Mar 29 '19 at 17:31
  • The first option doesn't work for me. I'm also not using CocoaPods for my project. Are there any other work arounds for this? – johnborges May 02 '19 at 20:11
  • Hi @johnborges - sorry I just saw your comment. If you are not using CocoaPods then you have a the same error but likely a completely different cause. I'm far from an expert on XCode so my best advice is to post a new question with as much details as possible. Sorry I can't help more – Mike Hardy May 21 '19 at 04:02
  • Excellent answer. Between React 5.x-6.x, CocoaPods and Firebase, successfully building for IOS and Android can be a nightmare sometimes – Dror Bar Mar 16 '20 at 18:02
  • Indeed! React-native 0.60+ made it much easier with auto-linking and cocoapods by default, but...it's still so hard! The price of portability for now. Glad the answer helped. – Mike Hardy Mar 17 '20 at 19:41
  • Showing Recent Issues I just saw the notice "The Legacy Build System will be removed in a future release. You can configure the selected build system and this deprecation message in File > Workspace Settings." I can't build in legacy anymore, how do I resolve this? – dytra Nov 18 '21 at 08:28
  • Update react-native, my update states clearly that react-native 0.60+ no longer needs this. In fact, react-native won't even build on Xcode12.5/Xcode13 until you update it to react-native 0.63.4. I can't see how this issue should still be affecting anyone. head over to https://react-native-community.github.io/upgrade-helper/ and update your project (ideally to 0.66.3) and clean out your podfile. Cheers – Mike Hardy Nov 18 '21 at 14:04