【问题标题】:Error on archiving react native app in Xcode - Multiple commands produce 'libyoga.a'在 Xcode 中存档反应本机应用程序时出错 - 多个命令产生“libyoga.a”
【发布时间】:2019-04-18 04:02:12
【问题描述】:

当我尝试使用 Xcode 中的发布配置归档我的 React Native 应用程序时出现错误 - 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'

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

【问题讨论】:

  • 你解决过这个问题吗?
  • @Matheswaaran - 我想我下面的回答可能解释了你的情况,你检查过吗?您现在有工作设置了吗?

标签: ios xcode reactjs react-native testflight


【解决方案1】:

[更新 20190926:如果你升级 react-native 0.60+,这是 cocoapods 原生的,这种事情不应该发生,我在下面发布的解决方法应该是不必要的]


如果我可以做出一些假设,您正在使用 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 中添加解决方法 sn-p[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 更改)

第三,您可以通过删除项目中对 react-native 框架的任何剩余引用(与 Pod 配置的工作区相反)来完成将项目完全转换为 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

【讨论】:

  • @Matheswaaran 你检查过这个吗?我很好奇我的答案是否适合你
  • 你忘了在编辑 Podfile 后从ios 文件夹运行pod install
  • 感谢@JulesRandolph,您是对的,如果您是 CocoaPods 新手(像我一样),这一步很容易忘记
  • 第一个选项对我不起作用。我也没有在我的项目中使用 CocoaPods。有没有其他解决方法?
  • 嗨@johnborges - 对不起,我刚刚看到你的评论。如果您没有使用 CocoaPods,那么您会遇到相同的错误,但可能是完全不同的原因。我远不是 XCode 方面的专家,所以我最好的建议是发布一个尽可能详细的新问题。抱歉,我帮不上忙
猜你喜欢
  • 2019-02-26
  • 2021-06-14
  • 2020-02-13
  • 1970-01-01
  • 2022-08-02
  • 2019-10-01
  • 1970-01-01
  • 2018-11-15
相关资源
最近更新 更多