SwiftEmitModule 正常的arm64 Emitting\ module\ for\ YogaKit(在项目“Pods”的目标“YogaKit”中)

use*_*363 13 xcode react-native

对于 React Native 0.70.1/Xcode 14/Monterey M1出现奇怪的错误npx react-native run-ios

The following build commands failed:
    SwiftEmitModule normal arm64 Emitting\ module\ for\ YogaKit (in target 'YogaKit' from project 'Pods')
Run Code Online (Sandbox Code Playgroud)

然而,Xcode 14 中的构建成功,没有任何错误。尝试在调试的构建设置中排除arm64(当前是i386),但没有解决。还在 pod 文件中添加以下块,但也没有修复:

   installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
      # some older pods don't support some architectures, anything over iOS 11 resolves that
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      end
    end
Run Code Online (Sandbox Code Playgroud)

Flo*_*bre 11

检查 PROJECT 和 Pod 的 Xcode 配置:

在此输入图像描述

在此输入图像描述

或者直接检查project.pbxproj文件,您应该有类似这样的用于发布或调试项目配置:

83CBBA211A601CBA00E9B192 /* Release */ = {
        isa = XCBuildConfiguration;
        baseConfigurationReference = 191954F424AC5C2600989E18 /* Config.xcconfig */;
// ....
 "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "i386";
Run Code Online (Sandbox Code Playgroud)

对于 Pod:

"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 i386";
/* for Pods-PSG.debug.xcconfig or Pods-PSG.release.xcconfig */
Run Code Online (Sandbox Code Playgroud)

拥有此配置应该允许基于 Intel x86_64 的模拟器构建以避免该错误。

我的Podfile也有这样的设置:

post_install do |installer|
  flipper_post_install(installer)

  react_native_post_install(installer)
  __apply_Xcode_12_5_M1_post_install_workaround(installer)
  
  // arm64 simulator EXCLUDED_ARCHS setting:
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

笔记:

  1. 上述 Podfile 代码针对 RN 0.66 和 RN 0.69 进行了测试
  2. 以上已在X86_64架构上进行了测试。请注意它仅针对模拟器,以排除当前架构的一些不支持的库。对于 M1,您需要检查要排除的架构并相应地调整 Xcode 和/或 Podfile 设置。

您还可以使用一些代码来检测当前架构并排除不支持的架构:

       #!/usr/bin/env ruby
       require 'xcodeproj'
       
       project = Xcodeproj::Project.open 'Foobar.xcodeproj'
       
       bad_arch = 'arm64'
       current_arch = `uname -m`.strip
       
       # xcode 12 on non-arm64 needs to exclude it for debug simulator builds so that we can test
       if current_arch != bad_arch
         project.build_settings('Debug')["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = bad_arch
         project.save
       end

Run Code Online (Sandbox Code Playgroud)

Podfile上述代码 来源: https://www.reddit.com/r/swift/comments/mw8djk/comment/gvi1rzh