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

TestFlight上传报错:AgoraRtmKit等框架bitcode验证失败求助

TestFlight上传Bitcode错误解决方案

问题背景

向TestFlight上传应用时触发报错:

Asset validation failed Invalid Executable. AgoraRtmKit' contains bitcode

提示AgoraRtmKit.framework和FBSDKCoreKit存在Bitcode问题。已在Xcode中设置ENABLE_BITCODE = NO,尝试两种Podfile配置仍无法解决:

  1. 第一种Podfile可完成归档,但上传仍报错;
  2. 第二种Podfile添加了多个框架的bitcode_strip处理,归档成功但上传依旧报Bitcode错误。

当前Podfile配置

配置一(可归档但上传报错)

# Uncomment this line to define a global platform for your project
platform :ios, '16.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Debug-dev' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

配置二(添加bitcode_strip后仍报错)

# Uncomment this line to define a global platform for your project
platform :ios, '16.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.generated_projects.each do |project|
    project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
         end
    end
end
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
     if target.name == 'MapboxMobileEvents'
        `xcrun -sdk iphoneos bitcode_strip -r Pods/MapboxMobileEvents/MapboxMobileEvents.xcframework/ios-arm64_armv7/MapboxMobileEvents.framework/MapboxMobileEvents -o Pods/MapboxMobileEvents/MapboxMobileEvents.xcframework/ios-arm64_armv7/MapboxMobileEvents.framework/MapboxMobileEvents`
      end

      if target.name == 'MapboxCommon'
        `xcrun -sdk iphoneos bitcode_strip -r Pods/MapboxCommon/MapboxCommon.xcframework/ios-arm64/MapboxCommon.framework/MapboxCommon -o Pods/MapboxCommon/MapboxCommon.xcframework/ios-arm64/MapboxCommon.framework/MapboxCommon`
      end

      if target.name == 'MapboxCoreMaps'
        `xcrun -sdk iphoneos bitcode_strip -r Pods/MapboxCoreMaps/MapboxCoreMaps.xcframework/ios-arm64/MapboxCoreMaps.framework/MapboxCoreMaps -o Pods/MapboxCoreMaps/MapboxCoreMaps.xcframework/ios-arm64/MapboxCoreMaps.framework/MapboxCoreMaps`
      end

      if target.name == 'AgoraRtmKit'
        `xcrun -sdk iphoneos bitcode_strip -r Pods/AgoraRtmKit/AgoraRtmKit.xcframework/ios-arm64/AgoraRtmKit.framework/AgoraRtmKit -o Pods/AgoraRtmKit/AgoraRtmKit.xcframework/ios-arm64/AgoraRtmKit.framework/AgoraRtmKit`
      end

      if target.name == 'FBAEMKit'
        `xcrun -sdk iphoneos bitcode_strip -r Pods/FBAEMKit/FBAEMKit.xcframework/ios-arm64/FBAEMKit.framework/FBAEMKit -o Pods/FBAEMKit/FBAEMKit.xcframework/ios-arm64/FBAEMKit.framework/FBAEMKit`
      end

      if target.name == 'FBSDKCoreKit'
        `xcrun -sdk iphoneos bitcode_strip -r Pods/FBSDKCoreKit/FBSDKCoreKit.xcframework/ios-arm64/FBSDKCoreKit.framework/FBSDKCoreKit -o Pods/FBSDKCoreKit/FBSDKCoreKit.xcframework/ios-arm64/FBSDKCoreKit.framework/FBSDKCoreKit`
      end

      if target.name == 'FBSDKCoreKit_Basics'
        `xcrun -sdk iphoneos bitcode_strip -r Pods/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics.xcframework/ios-arm64/FBSDKCoreKit_Basics.framework/FBSDKCoreKit_Basics -o Pods/FBSDKCoreKit_Basics/FBSDKCoreKit_Basics.xcframework/ios-arm64/FBSDKCoreKit_Basics.framework/FBSDKCoreKit_Basics`
      end

      if target.name == 'FBSDKLoginKit'
        `xcrun -sdk iphoneos bitcode_strip -r Pods/FBSDKLoginKit/FBSDKLoginKit.xcframework/ios-arm64/FBSDKLoginKit.framework/FBSDKLoginKit -o Pods/FBSDKLoginKit/FBSDKLoginKit.xcframework/ios-arm64/FBSDKLoginKit.framework/FBSDKLoginKit`
      end
  end
end

解决方案

针对这个问题,可以尝试以下几个步骤:

1. 强制所有Pods Target关闭Bitcode

修改Podfile的post_install阶段,统一关闭所有依赖框架的Bitcode,替代手动逐个设置:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    # 全局强制关闭所有Pods的Bitcode
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

2. 清理缓存后重新构建

  • 执行pod deintegrate清理现有Pods依赖
  • 删除项目根目录的Pods文件夹、Podfile.lock文件
  • 删除Xcode的Derived Data(可通过Xcode > Settings > Locations找到路径)
  • 重新执行flutter pub get和pod install
  • 清理Xcode项目(快捷键Cmd+Shift+K)后重新归档上传

3. 升级框架版本

部分旧版本的AgoraRtmKit或FBSDKCoreKit可能存在Bitcode兼容问题,尝试升级到最新稳定版本:

  • 在pubspec.yaml中更新对应的Flutter插件版本
  • 执行flutter pub get后重新执行pod install

4. 验证Bitcode是否彻底移除

归档完成后,可通过命令验证可执行文件是否还包含Bitcode:

# 替换为你的.app文件路径
otool -l /path/to/YourApp.app/YourApp | grep __LLVM

如果没有任何输出,说明Bitcode已彻底移除;若仍有输出,检查是否有遗漏的Target未关闭Bitcode。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.17 07:22:03