在Xcode中将React本机应用程序存档时出错-多个命令产生'libyoga.a'

时间:2018-11-15 05:18:00

标签: ios xcode reactjs react-native testflight

当我尝试使用Xcode中的发行版配置来归档我的React本机应用程序时出现错误-目标'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'

如何在新的构建系统中解决此问题?

1 个答案:

答案 0 :(得分:5)

如果我做出一些假设,则您正在使用react-native(已引用libyoga),您正在使用XCode 10+中的新构建系统(而不是旧系统),并且您已经集成了CocoaPods(可能使用Firebase或类似)。

如果我错了,请纠正我,但这是我的设置,这就是导致我出错的原因。

您有三种选择,以增加努力和正确性的顺序。

首先,您可以通过将构建切换到传统构建系统[1]来忽略/隐藏问题,从而毫不费力地移动这一刻:

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

第二,如果您在Podfile中添加了变通性代码段[2],直到问题在react-native或Cocoapods中得到解决,您就可以轻而易举地使用新的XCode构建系统。我现在正在执行此操作,我的项目已成功存档:

 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

(然后@ jules-randolph指出-您必须在iOS文件夹中运行pod install才能开始使用所做的Podfile更改)

第三,您可以通过删除项目中与本机框架(相对于Pods配置的工作空间)相对的剩余引用,来完成将项目完全转换为Pod的工作。[3]。我尚未执行此操作,但这是正确的操作,并已解决了上游问题。

参考文献,请注意一般来说,父问题很有用

[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