ios - 在 Xcode 中归档 native 应用程序时出错 - 多个命令产生 'libyoga.a'

标签 ios xcode reactjs react-native testflight

当我尝试使用 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'

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

最佳答案

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


如果我可以做一些假设,您正在使用 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 更改)

第三,您可以通过删除项目中对 react-native 框架的任何遗留引用(与由 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

关于ios - 在 Xcode 中归档 native 应用程序时出错 - 多个命令产生 'libyoga.a',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53312887/

相关文章:

reactjs - 如何向 React Bootstrap 轮播组件添加移动手势(例如触摸和滑动)?

reactjs - 属性 'location' 在类型 'Readonly<{}> 上不存在 - React Router 和 Typescript

ios - 如何在 iOS 上播放 mp3 从特定时间到特定时间(以毫秒为单位)?

ios - 如何在 Swift 中使用 ios-chart API 选择 chartValueSelected 时为 lineChart 启用弹出窗口?

xcode - 如何将一份代码连接到两个git仓库?

ios - 分享图像和文本 WhatsApp api iOS

ios - 如何在 UIScrollView 中旋转图像?

ios - 由于条件绑定(bind)错误的初始化程序,无法将文本 append 到字符串数组

ios - 如何从 Xcode 运行在 iPhone 上保留应用程序?

javascript - 链接不会使用 React DOM Router 重定向