React-Native:升级react和react-native后无法构建模块“Darwin”

pro*_*_98 7 xcode ios react-native apple-m1

将react-native包从0.63.4升级到0.64.4后,在模拟器和设备上构建和运行应用程序时,我在Xcode(在MacBook Pro M1上)中遇到以下错误:

在此输入图像描述

我尝试过使用或不使用脚蹼,但没有任何帮助。还手动将 CoreFoundation 和 Foundation Framework 添加到项目中,并在启用和不启用 Rosetta 的情况下运行 Xcode。

这是我当前的 PodFile:

source 'https://github.com/CocoaPods/Specs.git'

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '12.0'

target 'MyApp' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

  pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'

  pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'

  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"

   # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    #use_flipper!()

    post_install do |installer|
      react_native_post_install(installer)
    end
end
Run Code Online (Sandbox Code Playgroud)

Wed*_*tin 11

对我来说是Flipper。我没有在旧项目中使用它,它在我的新项目中自动启用。如果您的项目不需要,只需注释掉 Podfile 中的行即可。

# :flipper_configuration => FlipperConfiguration.enabled,
Run Code Online (Sandbox Code Playgroud)


pro*_*_98 -2

我的解决方案是使用您想要升级到的版本创建一个新的、干净的项目。然后执行以下步骤:

  1. 在 Xcode 中打开两个 .xcworkspace 文件
  2. 转到您的目标构建设置
  3. 搜索“标题搜索路径”
  4. 将所有标题搜索路径从新项目复制到要升级的项目
  5. 删除 DerivedData,清理构建并再次运行
  6. 运行 Pod 安装。也许您需要升级一些软件包

另外还有一个用于重建 .xcworkspace 的不错的 npm 脚本(将“[PRJECT_NAME]”替换为您的 .xcworkspace 名称):

"renew-pods-m1": "cd ios; rm -rf ~/Library/Caches/CocoaPods; rm -rf Pods; rm -rf [PROJECT_NAME].xcworkspace; rm -rf ~/Library/Developer/Xcode/DerivedData/*; pod deintegrate; pod setup; arch -x86_64 pod install;"
Run Code Online (Sandbox Code Playgroud)

注意:查看您的 PodFile。也许您需要更改 use_react_native 实现并添加 post_install 脚本

use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )
Run Code Online (Sandbox Code Playgroud)

在 PodFile 的末尾

# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
#use_flipper!()

post_install do |installer|
  react_native_post_install(installer)
end
Run Code Online (Sandbox Code Playgroud)