You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

M1设备下React Native iOS模拟器排除arm64架构pod install后重置问题

M1设备React Native iOS模拟器arm64架构自动排除配置方案

1. __apply_Xcode_12_5_M1_post_install_workaround(installer) 作用说明

这是React Native 0.64及以上版本官方内置的M1芯片适配补丁函数,核心作用是自动处理Xcode 12.5+在M1设备上的编译架构兼容问题,内置了模拟器SDK自动排除arm64架构、调整构建参数的逻辑,保留该行即可无需额外修改。

2. 现有脚本不生效的核心原因

你当前的post_install仅修改了Pods项目下所有依赖目标的构建配置,没有同步修改主项目的构建配置,导致手动修改的主项目规则每次pod install后被重置,出现需要反复手动配置的问题。

3. 修复后的完整配置

替换你现有Podfile中的post_install段为以下代码即可,执行pod install后会自动给主项目+所有Pods目标配置arm64排除规则,无需手动修改:

post_install do |installer|
  $RNMBGL.post_install(installer)
  react_native_post_install(installer)
  __apply_Xcode_12_5_M1_post_install_workaround(installer)

  # 处理所有Pods依赖的构建配置
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
    end
  end

  # 新增:处理主项目的构建配置,解决主项目规则被重置的问题
  installer.aggregate_targets.each do |aggregate_target|
    aggregate_target.user_project.targets.each do |app_target|
      app_target.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
        config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
      end
    end
    # 保存主项目的修改
    aggregate_target.user_project.save
  end
end

4. 生效验证步骤

修改完Podfile后按以下顺序操作即可:

  • 终端执行 pod deintegrate && pod install 完全重置Pods配置
  • 打开Xcode检查主项目和Pods项目的Excluded Architectures配置项,模拟器SDK对应栏已自动填充arm64
  • 按Command+Shift+K清理Xcode缓存后重新构建项目即可

内容的提问来源于stack exchange,提问作者denistepp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 08:24:05