React-native: 使用新的Xcode构建系统进行构建时,“多个命令产生”错误

创建于 2018-08-01  ·  69评论  ·  资料来源: facebook/react-native

你好,

环境:

React Native Environment Info:
    System OS: macOS High Sierra 10.13.6
    Binaries:
      Node: 8.11.3 - /usr/local/bin/node
      npm: 5.6.0 - /usr/local/bin/npm
    IDEs:
      Xcode: 10 Beta 3
    npmPackages:
      react: 16.4.1
      react-native: 0.56.0

错误:

当我尝试构建简单的RN 0.56应用程序时出现以下错误:

warning: Skipping duplicate build file in Compile Sources build phase: <PATH_TO_PROJECT>/node_modules/react-native/React/Modules/RCTRedBoxExtraDataViewController.m (in target 'React-tvOS')
...
warning: duplicate output file '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTResizeMode.h' on task: PBXCp <PATH_TO_PROJECT>/node_modules/react-native/Libraries/Image/RCTResizeMode.h <HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTResizeMode.h (in target 'React')
...
error: Multiple commands produce '<PbxCp <HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTScrollableProtocol.h>':
1) Target 'React-tvOS' has copy command from '<PATH_TO_PROJECT>/node_modules/react-native/React/Views/ScrollView/RCTScrollableProtocol.h' to '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTScrollableProtocol.h'
2) Target 'React' has copy command from '<PATH_TO_PROJECT>/node_modules/react-native/React/Views/ScrollView/RCTScrollableProtocol.h' to '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/React/RCTScrollableProtocol.h'
error: Multiple commands produce '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/double-conversion/fast-dtoa.h':
1) Target 'double-conversion-tvOS' has copy command from '<PATH_TO_PROJECT>/node_modules/react-native/third-party/double-conversion-1.1.5/src/fast-dtoa.h' to '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/double-conversion/fast-dtoa.h'
2) Target 'double-conversion' has copy command from '<PATH_TO_PROJECT>/node_modules/react-native/third-party/double-conversion-1.1.5/src/fast-dtoa.h' to '<HOME>/Library/Developer/Xcode/DerivedData/ReactNativeSimple-dpupkkuvhsslwxgngxzqgwsrazap/Build/Intermediates.noindex/ArchiveIntermediates/ReactNativeSimple/BuildProductsPath/Release-iphoneos/include/double-conversion/fast-dtoa.h'
...

复制步骤:

  • 反应本征
  • xcodebuild -project <PATH_TO_PROJECT>/ios/ReactNativeSimple.xcodeproj -scheme ReactNativeSimple archive -sdk iphoneos -archivePath <PATH_TO_PROJECT>/output/build/archive/ReactNativeSimple CODE_SIGN_STYLE=Automatic

细节:

我在由“ react-native init ”命令创建的简单RN应用程序上进行了测试。
当我尝试使用Xcode 10 GUI构建应用程序时-它构建成功。
但是我尝试使用xcodebuild命令来构建它-失败,并出现上述错误。

当我们在Xcode 9.4.1的同一应用程序(RN 0.56)上使用同一命令时-它会成功构建
如果我没有在xcodebuild命令中指定-sdk param,它将成功构建。
注意:_对于不同的Xcode 10 Beta版本,错误可能有所不同。_

问题:

RN 0.56是否支持Xcode 10 Beta?
我该如何解决?
是否有使用Xcode 10 Beta进行构建的解决方法?

Bug iOS Locked

最有用的评论

您可以尝试将构建系统更改为旧版,
文件>工作区设置>构建系统>旧版构建系统。

所有69条评论

您可以尝试将构建系统更改为旧版,
文件>工作区设置>构建系统>旧版构建系统。

我们要使用新的构建系统。

应该支持新的构建系统。 我们正在跟踪人们在此任务中使用Xcode 10或新构建系统遇到的任何问题: https :

乍一看,到目前为止,我们在master上已解决的问题似乎并未涵盖您的问题。 我将其添加到列表中。

我还遇到libReact.alibyoga.aMultiple commands produce错误。
我正在使用:

  • Xcode 10
  • react-native 0.57.0
  • 可可豆

为了克服这个问题,我将其添加到我的Podfile

  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

然后使用以下命令重建您的Pods项目:

$ pod install

完整的环境详细信息:


  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 4.10 GB / 32.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.9.0 - ~/.nvm/versions/node/v10.9.0/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.9.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
    IDEs:
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0
      react-native: 0.57.0 => 0.57.0
    npmGlobalPackages:
      create-react-native-app: 1.0.0
      react-native-cli: 2.0.1

确认@PaulMest的解决方法有效。 从Pods项目的Targets中手动删除Xcode中的Yoga也应该起作用,就像我一直在使用React一样,它在RN 0.57之前也导致重复的目标构建错误。

如果您使用的是xcodebuild ,请附加此-UseModernBuildSystem=NO以加入旧的旧版构建系统

@PaulMest谢谢,我今天过

希望我的情况可以帮助你们解决问题!

这是完整的输出:

:-1: Multiple commands produce '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Roboto.ttf':
1) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/native-base/Fonts/Roboto.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Roboto.ttf'
2) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/src/Resources/Fonts/Roboto.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Roboto.ttf'

:-1: Multiple commands produce '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Zocial.ttf':
1) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/native-base/Fonts/Zocial.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Zocial.ttf'
2) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/react-native-vector-icons/Fonts/Zocial.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Zocial.ttf'

:-1: Multiple commands produce '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Ionicons.ttf':
1) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/native-base/Fonts/Ionicons.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Ionicons.ttf'
2) Target 'zonder' (project 'zonder') has copy command from '/Users/ntomallen/source/zonder-mobile-app/node_modules/react-native-vector-icons/Fonts/Ionicons.ttf' to '/Users/ntomallen/Library/Developer/Xcode/DerivedData/zonder-bkcoqubqbalyhffxhurxhkuivvms/Build/Products/Debug-iphonesimulator/zonder.app/Ionicons.ttf'

本质上, react-native-vector-iconsnative-base都捆绑相同的字体文件。 (由于某种原因,我们也将其中一个捆绑在一起;我一定会删除它。)在更新为Xcode 10 / Mojave之前,没有问题。 唯一的更改是从Xcode 9更新到Xcode 10。

@ntomallen我遇到了与react-native-vector-iconsnative-base重复字体完全相同的问题,最终我要做的是从目标应用程序的Copy Resources To Bundle部分中删除重复的字体。 此后,我的项目再次工作(好吧,它移至两个不同的错误,在这里进行了描述:找不到libfishhook.a-修复,并且libReact.a和libyoga.a的多个命令产生错误-修复

到目前为止,我的应用程序运行良好,可以使用XCode 10的新构建系统进行编译。

_免责声明:我不是一位经验丰富的iOS开发人员,因此一起破解了这些解决方案。 我不知道我是否弄乱了我不知道的东西。

这也正是对我有用的! 尽管我仍然很好奇为什么现在突然却是以前的错误。
在2018年9月26日下午2:49 -0400,尼尔斯·博克曼(Niels Bokmans) [email protected]写道:

@ntomallen我遇到了完全相同的问题,来自react-native-vector-icons和native-base的重复字体,最​​后我要做的是从目标应用程序的“将资源复制到捆绑”部分中删除重复的字体。 此后,我的项目再次工作(好吧,它移至两个不同的错误,在这里进行了描述:找不到libfishhook.a-修复,并且libReact.a和libyoga.a的多个命令产生错误-修复
到目前为止,我的应用程序运行良好,可以使用XCode 10的新构建系统进行编译。
免责声明:我不是经验丰富的iOS开发人员,并且一起破解了这些解决方案。 我不知道我是否弄乱了我不知道的东西。
-
您收到此邮件是因为有人提到您。
直接回复此电子邮件,在GitHub上查看,或使该线程静音。

@ntomallen基本上是因为有一个新的“

好。 这太疯狂了。 我切换到旧版构建系统。 现在,我得到了另一个错误。

/Users/michaelstelly/Documents/projects/mobile_gtm/node_modules/react-native/React/../third-party/glog-0.3.4/src/base/mutex.h:105:10: fatal error: 'config.h' file not found
#include "config.h"           // to figure out pthreads support

除了显而易见的以外,我不知道这意味着什么-文件丢失。 但是在Xcode 10之前,我没有任何构建问题。

@mjstelly你是0.57吗? 您的错误消息中提到glog-0.3.40.57使用glog-0.3.5 。 我只想确保我们正在跟踪最新版本中的问题。

@PaulMest我的英雄! 谢谢!

你好@mjstelly

您是否面临与第三方类似的问题?
我正在使用xcode 10

  1. 在/Users/ehs-mobile-app/node_modules/react-native/third-party/folly-2016.09.26.00/folly/json中包含的文件中。 cpp:17

Xcode 10.1似乎在两个系统上都可以正常构建,但是我无法在两个系统上都存档,因此会出现许多构建错误。 现在做什么?

您必须更具体。 在MacOS 10.12.6和RN 0.57.0上,Xcode 10可以很好地构建和归档(解决了我现在不记得的一些错误)。

我的Podfile post_install看起来像这样:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
    if target.name == 'yoga'
      target.remove_from_project
      target.build_configurations.each do |config|
          config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO'
          config.build_settings['GCC_WARN_64_TO_32_BIT_CONVERSION'] = 'NO'
      end
    end
  end
end

遵循@PaulMest的建议为我工作。

@njbmartin谢谢!
只有你的修复对我有用

-UseModernBuildSystem =否

这对我有用。 我花了很长时间才找到这个。 谢谢。

切换到旧版构建系统可修复许多构建错误,但我们确实需要能够在未来使用现代系统:p

此外,祝大家庆祝感恩节快乐!

是的,新版本固然不错,但并不是那么顺利。
有风险升级。

@PaulMest谢谢。 您的骇客作品:)

确认@PaulMest的解决方法有效。 从Pods项目的Targets中手动删除Xcode中的Yoga也应该起作用,就像我一直在使用React一样,它在RN 0.57之前也导致重复的目标构建错误。

究竟如何做到这一点@fungilation

这是#19573中剩下的唯一已知的阻止程序。 人们是否仍在0.57.8中遇到此问题?

从0.57.8开始我一般对Xcode都没有问题

@hramos不幸的是没有。 对我来说,0.57.8和新的0.58.0-rc.3仍然需要Xcode旧版构建选项(编辑:也为0.58.3)。

为了使此过程可重现,我创建了一个新的新项目,并在本地使用travis CI对其进行测试。 我将下面的原始项目(但它只是使用react-native init创建的)与成功的和失败的travis链接在一起。 也许有帮助吗? 当有新版本可用时,至少我可以并且将重新运行该实验。

@hramos我使用排毒而不是yarn ios运行构建时遇到了它。 这是我的iOS模拟器的配置:

{
    "configurations": {
        "ios.sim.debug": {
            "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/reactipay.app",
            "build": "xcodebuild -project ios/reactipay.xcodeproj -scheme reactipay -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
            "type": "ios.simulator",
            "name": "iPhone 6"
        },
        "android.emu.debug": {
            "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
            "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
            "type": "android.emulator",
            "name": "emulator-5554"
        }
    },
    "test-runner": "jest"
}

具体来说,如果我运行以下命令: xcodebuild -project ios/reactipay.xcodeproj -scheme reactipay -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build它将失败,并显示原始错误。

我还遇到libReact.alibyoga.aMultiple commands produce错误。
我正在使用:

  • Xcode 10
  • react-native 0.57.0
  • 可可豆

为了克服这个问题,我将其添加到我的Podfile

  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

然后使用以下命令重建您的Pods项目:

$ pod install

完整的环境详细信息:

天哪!

我对此错误非常困惑,因为它似乎不一致。 如果我运行构建命令10次,它最终可能会开始工作
这是mu e2e脚本的外观

detox build -c ios.sim.releas ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release ||
 detox build -c ios.sim.release

排毒的地方在哪里

xcodebuild -project ios/deliverypoc.xcodeproj -scheme deliverypoc -configuration Release -sdk iphonesimulator -derivedDataPath ios/build

我无法使用旧版构建系统,因为它挂在react build上,并且我不使用Cocoa Pods。
还有什么其他解决方案?
我可以将我的iOS迁移到Cocoa吗? 它会带来什么影响?

@ pavlof01我正在特别寻找有关0.57.8或更高版本上仍在发生的报告。

@hramos我在0.57.8和0.58.3的Xcode 10.1上仍然有这个。 我没有尝试使用旧版构建系统运行(现在是官方修复程序吗?),相反,当name == "React"name == "yoga"时,我使用Podfile到target.remove_from_project name == "yoga" 。 我也没有尝试过Xcode 9等,就像@jerolimov在上面一样。

对于我们来说,这不是一个阻碍性的问题,但是尽管我会鸣叫! 如果可以提供更多有用的信息,请告诉我。

请注意,当我说我对RN 0.57.8不再有任何问题时,我也在Podfile中使用此替代方法:

post_install do |installer|
  installer.pods_project.targets.each do |target|

    targets_to_ignore = %w(React yoga)

    if targets_to_ignore.include? target.name
      target.remove_from_project
    end

  end
end

忘了😛

@hramos我正在使用0.57.8(相同错误)-如果您需要任何其他信息,请告诉我。

我也遇到了排毒问题。 我通过在xcodebuild中指定一个目标而不是在sdk中来修复它: -destination 'platform=iOS Simulator,name=iPhone 7'

可以确认它在存档步骤中发生在0.58.3上。 将remove_from_project解决方法添加到我的podfile中即可解决该问题。 react-native info

$ $(npm bin)/react-native info

  React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
      Memory: 1.13 GB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.0.0 - /usr/local/bin/node
      Yarn: 1.10.1 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 19, 21, 22, 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.3, 27.0.3, 28.0.1, 28.0.2, 28.0.3
        System Images: android-19 | Google APIs Intel x86 Atom, android-21 | Google APIs Intel x86 Atom_64, android-22 | Google APIs Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-24 | Google APIs Intel x86 Atom_64, android-24 | Google Play Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom_64, android-25 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom_64
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmGlobalPackages:
      react-native-cli: 2.0.1

谢谢@aaronjensen在这个上

自58年以来,我一直在使用新的构建系统,没有任何问题。

我确实遇到了如上所述的Multiple commands produce *问题,但这是由于我切换到Pods(链接)之前的剩余食物所致; 如果您现在正在使用Pods,请确保从Xcode项目(而不是生成的工作空间)中删除所有与React Native相关的Linked Frameworks and Libraries

清理并切换到通过Pods使用RN后,它应该看起来像这样:

image

而且不是这样的:
image

注意,旧的构建系统忽略了这些重复,试图通过链接和pod一起使用RN。 新的构建系统没有; 所以您可能已经有一段时间了。

如果您要使用xcodebuild进行Detox的构建,请确保从上面将@aaronjensen的建议应用于构建命令。

@salakar Ive一直在做同样的事情。 要注意的一件事是,如果您手动链接了没有Pod的第三方Libray,则可能很难找到React Native。 基本上尝试将所有内容切换到Pod。

根据@Salakar的评论关闭。

@cpojer恕我直言,如果使用react-native init创建一个简单项目后解决方案需要手动步骤,则无法解决此问题。 这不是新用户所期望的。 默认值应该可以正常工作,而无需在Xcode中进行任何更改,也不需要CocoaPods。 (尽管CocoaPods很棒,并且可以在RN😏上正常工作)

如前所述,我使用react-native init创建了一个示例应用程序,并在Travis CI上运行了该应用程序。 这很好地说明了该构建可与Xcode 9和Xcode 10与旧版构建系统一起很好地工作。 而且它不适用于Xcode 10的新构建系统。

您可以在GitHub上查看构建历史记录,主文件已经是0.59.0-rc.1,并且仍然存在相同的问题。

Travis CI上提供了不同分支的构建历史记录(主版本为Xcode 9,Xcode 10有两个分支),以及GitHub Pull Request

如前所述。 恕我直言。 😏

@jerolimov您的构建未指定目的地,这似乎是必不可少的,因为否则它会尝试为tvOS和iOS都构建构件,这会导致您遇到的问题。

尚不清楚的是,RN是否可以执行某些操作,从而导致新的构建系统隐式知道您想要的内容,或者这实际上仅仅是xcode中的错误(在这种情况下,这是该问题的错误存储库) 。

鉴于@Salakar的评论

切换为开始使用Pod时,我似乎没有正确清理链接的框架和库。 任何人都可以提供有关正确过程的更多详细信息来删除那些链接吗?

在Xcode中,右键单击所有引用React Native的东西(通常在侧栏中的Frameworks或Libraries下),然后选择“删除引用”。 在此过程结束时,请确保“链接库和框架”部分没有对React Native的引用。 请注意,这样做时,您其他依赖React Native的第三方库也应通过Pods链接。 (大多数主要的支持它,这很好。)

我也遇到了排毒问题。 我通过在xcodebuild中指定一个目标而不是在sdk中来修复它: -destination 'platform=iOS Simulator,name=iPhone 7'

@aaronjensen您能否提供完整的代码示例?

"xcodebuild -project ios/AppName.xcodeproj -scheme AppName -configuration Debug -derivedDataPath ios/build -destination 'platform=iOS Simulator, name=iPhone 7'"

当然,您所拥有的看起来很像我们正在使用的。

xcodebuild -project ios/AppName.xcodeproj -scheme AppName -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 7' -derivedDataPath ios/build

我还遇到libReact.alibyoga.aMultiple commands produce错误。
我正在使用:

  • Xcode 10
  • react-native 0.57.0
  • 可可豆

为了克服这个问题,我将其添加到我的Podfile

  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

然后使用以下命令重建您的Pods项目:

$ pod install

完整的环境详细信息:


  React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.6
      CPU: x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 4.10 GB / 32.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.9.0 - ~/.nvm/versions/node/v10.9.0/bin/node
      Yarn: 1.9.4 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.9.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
    IDEs:
      Xcode: 10.0/10A255 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.5.0 => 16.5.0
      react-native: 0.57.0 => 0.57.0
    npmGlobalPackages:
      create-react-native-app: 1.0.0
      react-native-cli: 2.0.1

做得好
rm -rf Pods; pod install为我工作

@Salakar从Xcode项目的Linked Frameworks and Libraries中删除所有RCT *库在iOS中成功构建,但出现Native module cannot be null错误。 而且只有在我添加了libReact.a和其他libRCT*.a库之后,构建才起作用。 我们正在使用Pods来管理其他依赖项。

以下是我们的Podfile的外观,

``源'' https://github.com/CocoaPods/Specs.git '

您项目的全球平台

平台:ios,“ 9.0”

进入CocoaPods库中的所有警告。

hibit_all_warnings!
插件“ cocoapods-fix-react-native”

目标“ RNMobile”
#如果您使用的是Swift或想使用动态框架,请取消注释下一行
#use_frameworks!

#RNMobile的基本豆荚
pod'React',:path =>'../node_modules/react-native',:subspecs => [
'核心',
“ CxxBridge”,
'DevSupport',
#以下是Xcode中“库”中的内容:
“ RCTAnimation”,
“ RCTActionSheet”,
“ RCTBlob”,
“ RCTGeolocation”,
“ RCTImage”,
“ RCTLinkingIOS”,
“ RCTNetwork”,
“ RCTSettings”,
“ RCTText”,
“ RCTVibration”,
'RCTWebSocket'
]

#以下依赖关系是React native本身的依赖关系。
pod'yoga',:path =>'../node_modules/react-native/ReactCommon/yoga/Yoga.podspec'
pod'DoubleConversion',:podspec =>'../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod'Folly',:podspec =>'../node_modules/react-native/third-party-podspecs/Folly.podspec'
pod'glog',:podspec =>'../node_modules/react-native/third-party-podspecs/GLog.podspec'

#WahedMobile的额外豆荚
pod'AppCenter / Crashes','〜> 1.13.0'
pod'AppCenter / Analytics','〜> 1.13.0'
pod'AppCenterReactNativeShared','〜> 1.12.0'
pod'RNVectorIcons',:path =>'../node_modules/react-native-vector-icons'
pod'lottie-react-native',:path =>'../node_modules/lottie-react-native'
pod'lottie-ios',:path =>'../node_modules/lottie-ios'
pod'RNAWSCognito',:path =>'../node_modules/amazon-cognito-identity-js'
pod'TouchID',:path =>'../node_modules/react-native-touch-id'
pod'BVLinearGradient',:path =>'../node_modules/react-native-linear-gradient'
pod'RNGestureHandler',:path =>'../node_modules/react-native-gesture-handler'
pod'RNSVG',:path =>'../node_modules/react-native-svg'
pod'react-native-camera',:path =>'../node_modules/react-native-camera'

pod'CodePush',:path =>'../node_modules/react-native-code-push'

pod'RNAnalytics',:path =>'../node_modules/@segment/analytics-react-native'

#Firebase库
pod'Firebase / Core','〜> 5.15.0'
pod'Firebase / Messaging','〜> 5.15.0'

#Onfido Libs
pod'Onfido','10 .3.0',:configurations => ['Debug']
pod'Onfido-Release','10 .3.0',:configurations => ['Release']

pod'RNKeychain',:path =>'../node_modules/react-native-keychain'

结束
```

另外,在Linked Frameworks and Libraries添加库会在AppCenter中创建重复的符号错误。

对于要升级到59并且具有Pod的React本机用户的参考:
在上面@anandwahed的解决方案之上,我结束了1-分析XCode中的项目,然后2-手动删除了所有带有tvOS的目标。

我的Podfile post_install看起来像这样:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == 'react-native-google-maps'
      target.build_configurations.each do |config|
        config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
      end
    end
    if target.name == "React"
      target.remove_from_project
    end
    if target.name == 'yoga'
      target.remove_from_project
      target.build_configurations.each do |config|
          config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO'
          config.build_settings['GCC_WARN_64_TO_32_BIT_CONVERSION'] = 'NO'
      end
    end
  end
end

遵循@PaulMest的建议为我工作。

您的解决方案对我有用,坦克。

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

那并杀死了旧的地铁打包机实例,这对我有所帮助。

我遇到了这个问题,我没有使用cocoapods。 我正在使用react-native-navigation,因此无法使用cocoapods。

@MakhouT使用react-native-navigation不会限制您使用cocoapods

@AngefloMusic React-native-navigation没有使用它,对于设置,您需要更改一些本机iOS文件。 使用cocoapods时,我假设在安装pod依赖项时这会相互冲突。 但是我不确定,因为我没有太多可可粉。 所以,如果我错了,请纠正我。

@MakhouT他们没有冲突。 实际上,如果您查看react-native-navigation回购,您会看到有一个podspec文件。 我现在在一个项目中将RNN与cocoapods一起使用。

抱歉,我需要重新打开它,但是在尝试生成归档文件时,最优选的解决方案(请参见下面的Podfile)使我遇到这个痛苦的错误。

immagine

这是我的podfile

# Uncomment the next line to define a global platform for your project
platform :ios, '10.1'

target 'TVTips' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  #use_frameworks!

  # Pods for TVTips
  pod 'Firebase/Core', '~> 5.20.1'
  pod 'Firebase/Analytics', '~> 5.20.1'
  pod 'Firebase/Auth'
  pod 'GoogleSignIn', '~> 4.4.0'
  pod 'TwitterKit', '~> 3.3.0'
  pod 'React', :path => '../node_modules/react-native', :modular_headers => true
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
  pod 'react-native-twitter-signin', :path => '../node_modules/react-native-twitter-signin'

  target 'TVTips-tvOSTests' do
    inherit! :search_paths
    # Pods for testing

    pod 'YouTubeSdk', :path => '../node_modules/react-native-youtube-sdk'

    pod 'ReactNativeLocalization', :path => '../node_modules/react-native-localization'

    pod 'RNShare', :path => '../node_modules/react-native-share'

  end

  target 'TVTipsTests' do
    inherit! :search_paths
    # Pods for testing
  end

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      if target.name == "React"
        target.remove_from_project
      end

      targets_to_ignore = %w(React yoga)

      if targets_to_ignore.include? target.name
        target.remove_from_project
      end

    end
  end

end

我已经在带有库的Link Binary和链接的框架和库中导入了React。
救命 :)

对我来说,删除内部重复的资源

建造阶段
像下面这样,字体出错了

image

我知道这对于将RN迁移到Pods的人或使用RN> 0.60.x的人来说是一个已解决的问题,但是如果您还没有准备好或正在迁移,这是我们的临时解决方案(它基本上从React Native pbxproj文件中删除了tvOS config,这似乎导致了多个目标)。

我们在安装后脚本中使用它

const xcode = require('xcode');
const fs = require('fs');
const path = require('path');

const reactNativeProjectPath = path.resolve(__dirname, '../node_modules/react-native/React/React.xcodeproj/project.pbxproj');
const myProj = xcode.project(reactNativeProjectPath);

myProj.parse(err => {
    if (err) {
        throw err;
    }

    const nativeTargets = myProj.hash.project.objects.PBXNativeTarget;

    Object.keys(nativeTargets).forEach(nativeTargetKey => {
        const target = nativeTargets[nativeTargetKey];
        if (target.name && target.name.indexOf('-tvOS') !== -1) {
            console.log(`Removing ${target.name}:${nativeTargetKey} in React pbxproj`);
            delete nativeTargets[nativeTargetKey];
        }
    });

    fs.writeFileSync(reactNativeProjectPath, myProj.writeSync());
    console.log(`All mentioned of tvOS removed in React pbxproj`);
});

对于使用Fastlane并遇到此问题的用户, @ PaulMest解决方案有效:将所有必需的目标添加到target_to_ignore,然后在运行Fastlane之前运行rm -rf ios/Pods && pod install

对我来说,删除内部重复的资源

建造阶段
像下面这样,字体出错了

image

添加到@aerda的答案中,我从“构建阶段”>“复制捆绑包资源”中删除了react-native-vector-icons使用的所有字体(.tff文件),并且现在正在构建我的项目。

我认为在我的情况下,此错误与更新到XCode 11有关,但对最后一部分并不满意。

只有在今天升级到Xcode 11稳定版(Mac 10.14.6)之后,我才能确认字体重复是否相同。 删除Xcode的“构建阶段”的[CP] Copy Pods Resources部分下的字体,然后再次进行构建。

曾经并且正在使用New build system。 在RN 0.60.5上。

@fungilation与我相同(Xcode 11-今天升级,新的构建系统和RN 0.60.5)。 我必须删除Copy Bundle Resources下的所有字体,并且它可以工作。

但是当我下次执行pod install命令时,此条目将再次出现

此处与0.61.0-rc.3和xcode 11 11A420a mojave 10.14.6相同

我只删除了react-native-vector-icons tff,它起作用了。 无需删除所有tff

删除以前的Pod,安装Pod,然后运行update pod,它将起作用。

这是我添加到我的podfile中的内容:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end

    if target.name == "yoga"
      target.remove_from_project
    end
  end

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf'
    end
  end
end

这是我添加到我的podfile中的内容:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if target.name == "React"
      target.remove_from_project
    end

    if target.name == "yoga"
      target.remove_from_project
    end
  end

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf'
    end
  end
end

我尝试了此命令(使用fastlane),但即使这样,错误仍然存​​在。 😢

error: Multiple commands produce '.../UninstalledProducts/iphoneos/libRNGestureHandler.a':

对于已安装的其他4个库,我也收到类似的错误-
RNKeyChain,RNAsyncStorage,RNDeviceInfo和BVLinearGradient

这是我的环境-

System:
    OS: macOS 10.15.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 1.54 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 12.10.0 - /usr/local/bin/node
    Yarn: 1.17.3 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 23, 26, 27, 28, 29
      Build Tools: 27.0.3, 28.0.3, 29.0.1
      System Images: android-19 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5977832
    Xcode: 11.2/11B52 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: ^0.60.5 => 0.60.5 
  npmGlobalPackages:
    react-native-cli: 2.0.1

自从早上以来一直在尝试寻找解决方案,但到目前为止没有任何发现。 👎
即使在模拟器中运行,它也可以正常工作。

只有在今天升级到Xcode 11稳定版(Mac 10.14.6)之后,我才能确认字体重复是否相同。 删除Xcode的“构建阶段”的[CP] Copy Pods Resources部分下的字体,然后再次进行构建。

曾经并且正在使用New build system。 在RN 0.60.5上。

对于像我这样的新手:您需要编辑文件<PROJECT_FOLDER>/ios/<PROJECT_NAME>.xcodeproj/project.pbxproj

然后像这样注释掉字体行(以.ttf结尾的文件):

inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-drawer2/Pods-drawer2-resources.sh", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/AntDesign.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Entypo.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Feather.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome5_Brands.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome5_Regular.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/FontAwesome5_Solid.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Fontisto.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Foundation.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Octicons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf", // "${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Zocial.ttf", ); name = "[CP] Copy Pods Resources"; outputPaths = ( // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AntDesign.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Entypo.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/EvilIcons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Feather.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome5_Brands.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome5_Regular.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FontAwesome5_Solid.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Fontisto.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Foundation.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Ionicons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MaterialCommunityIcons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/MaterialIcons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Octicons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SimpleLineIcons.ttf", // "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Zocial.ttf", );

而且每次我运行pod install ,我都必须重做此过程

此页面是否有帮助?
0 / 5 - 0 等级