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

使用GitHub Actions+Fastlane构建Expo React Native项目归档失败

React Native Expo项目GitHub Actions+Fastlane构建失败:Pod依赖部署目标不兼容Xcode15

问题详情

使用GitHub Actions结合Fastlane构建React Native Expo项目时,归档步骤失败。错误日志显示多个Pod依赖的IPHONEOS_DEPLOYMENT_TARGET被设置为11.0,但当前使用的Xcode 15.0.1支持的iOS部署目标范围是12.0-17.0.99,最终导致构建终止。

项目环境参数:

  • React Native: 0.72.0
  • Expo: 49.0.15
  • 运行环境:macos-latest
  • Node.js: 16.x
  • Ruby: 3.0.2
  • Fastlane Action: maierj/fastlane-action@v3.0.0

Fastfile相关配置代码:

def delete_temp_keychain(name)
  delete_keychain(
    name: name
  ) if File.exist? File.expand_path("~/Library/Keychains/#{name}-db")
end

def create_temp_keychain(name, password)
create_keychain(
  name: name,
  password: password,
  unlock: false,
  timeout: 0
)
end

def ensure_temp_keychain(name, password)
  delete_temp_keychain(name)
  create_temp_keychain(name, password)
end

platform :ios do 
  desc "iOS Build and Deploy to TestFlight"
  lane :testflight do
    # xcodes(
    #   version: "15.4",
    #   select_for_current_build_only: true
    # )
    keychain_name = "temp_keychain_username"
    keychain_password = "temp_keychain_password"
    ensure_temp_keychain(keychain_name, keychain_password)

    # Debugging logs for environment variables
    puts "Environment Variables:"
    puts "APPLE_API_KEY_ID: #{ENV['APPLE_API_KEY_ID']}"
    puts "APPLE_ISSUER_ID: #{ENV['APPLE_ISSUER_ID']}"
    puts "BUNDLE_ID: #{ENV['BUNDLE_ID']}"
    puts "APPLE_TEAM_ID: #{ENV['APPLE_TEAM_ID']}"
    puts "GIT_PERSONAL_ACCESS_TOKEN: #{ENV['GIT_PERSONAL_ACCESS_TOKEN'] ? 'Present' : 'Missing'}"

    increment_build_number(
      xcodeproj: xcodeproj,
      build_number: ENV['BUILD_NUMBER']
    )
    increment_version_number(
      xcodeproj: xcodeproj,
      version_number: ENV['VERSION_NUMBER']
    )

    cocoapods(
      clean_install: false,
      podfile: File.absolute_path('../ios/Podfile')
    )

    api_key = app_store_connect_api_key(
      key_id: ENV['APPLE_API_KEY_ID'],
      issuer_id: ENV['APPLE_ISSUER_ID'],
      key_filepath: File.absolute_path("../AppleApiKey.p8"),
      duration: 1200,
      in_house: false
    )

    sync_code_signing(
      type: "appstore",
      team_id: ENV['APPLE_TEAM_ID'],
      app_identifier: ENV['BUNDLE_ID'],
      git_basic_authorization: Base64.strict_encode64(ENV['GIT_PERSONAL_ACCESS_TOKEN']),
      keychain_name: keychain_name,
      keychain_password: keychain_password,
      git_url: github_match_url,
      api_key: api_key
    )

    update_project_provisioning(
      xcodeproj: xcodeproj,
      target_filter: ios_app_scheme,
      profile: ENV["sigh_#{ENV['BUNDLE_ID']}_appstore_profile-path"],
      build_configuration: "Release"
    )

    update_project_team(
      path: xcodeproj,
      teamid: ENV['APPLE_TEAM_ID']
    )
    build_app(
      clean: true, # Ensure clean build
      export_team_id: ENV['APPLE_TEAM_ID'],
      configuration: "Release",
      workspace: xcworkspace,
      scheme: ios_app_scheme,
      export_method: "app-store",
      export_options: {
        provisioningProfiles: {  
          ENV['BUNDLE_ID'] => appstore_provision_file
        }
      }
    )
    
    upload_to_testflight(
      apple_id: ENV['APPLE_APP_ID'],
      app_identifier: ENV['BUNDLE_ID'],
      skip_waiting_for_build_processing: true,
      skip_submission: true,
      distribute_external: false,
      notify_external_testers: false
    )

    version = get_version_number(xcodeproj: xcodeproj)
    build = get_build_number(xcodeproj: xcodeproj)
    clean_build_artifacts
    git_commit(
      path: [File.absolute_path(plist_file_path)],
      message: ios_commit_message
    )
    push_to_git_remote

    delete_temp_keychain(keychain_name)
  end
end

解决方案

1. 强制统一Pod依赖的部署目标

在iOS目录的Podfile末尾添加post_install钩子,强制所有Pod的部署目标与项目保持一致(至少12.0):

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # 统一设置为12.0,适配Xcode15要求
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end

同时确保项目本身的部署目标也设置为12.0及以上,可以通过Fastlane在构建前更新项目配置:

# 添加到testflight lane的cocoapods步骤前
update_xcode_project(
  xcodeproj: xcodeproj,
  target: ios_app_scheme,
  build_setting: {
    'IPHONEOS_DEPLOYMENT_TARGET' => '12.0'
  }
)

2. 清理并重新安装Pod依赖

将Fastfile中cocoapods步骤的clean_install改为true,确保重新安装Pod时应用新的部署目标设置:

cocoapods(
  clean_install: true,
  podfile: File.absolute_path('../ios/Podfile')
)

3. 可选:切换兼容的Xcode版本

如果暂时无法升级所有依赖到支持iOS12+,可以在Fastlane中指定使用Xcode14.x版本(支持iOS11部署目标),取消注释Fastfile中的xcodes配置:

xcodes(
  version: "14.3.1",
  select_for_current_build_only: true
)

4. 本地验证

在提交到GitHub Actions之前,本地执行pod install和fastlane ios testflight构建,确认修改生效,避免CI环境重复失败。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 16:43:12