Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error on archiving react native app in Xcode - Multiple commands produce 'libyoga.a'

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?

like image 997
Matheswaaran Avatar asked Nov 15 '18 05:11

Matheswaaran


1 Answers

[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

like image 88
Mike Hardy Avatar answered Oct 15 '22 17:10

Mike Hardy