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

使用Fastlane在GitLab Runner构建ReactNative iOS应用时遇[CP-User] [RNFB]配置错误

解决React Native iOS构建中[RNFB] Core Configuration脚本阶段的重复执行警告

问题背景

使用GitLab Runner(macos-14-xcode-15镜像,Xcode 15.4)通过Fastlane构建React Native iOS应用时,遇到以下警告:

Run script build phase '[CP-User] [RNFB] Core Configuration' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'dxp' from project 'dxp')

手动在Xcode中取消勾选"Based on dependency analysis"无效,因为该脚本阶段由react-native-firebase通过CocoaPods自动生成,每次执行pod install都会重置Xcode项目设置。

解决方案

方案1:通过Podfile持久化修改脚本阶段设置

在iOS目录下的Podfile末尾添加post_install钩子,自动修改目标脚本阶段的配置,避免被pod install覆盖:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    # 替换为你的项目Target名称,这里是'dxp'
    next unless target.name == 'dxp'

    target.script_phases.each do |phase|
      next unless phase.name == '[CP-User] [RNFB] Core Configuration'

      # 禁用依赖分析,强制每次构建执行(等效于取消Xcode中的"Based on dependency analysis"勾选)
      phase.run_only_for_deployment_post_processing = true

      # 可选:添加虚拟输出文件让Xcode识别脚本执行产物,也可消除警告(二选一即可)
      # phase.output_paths = ['$(DERIVED_FILE_DIR)/RNFB_Core_Configuration_Marker']
    end
  end
end

添加后,执行pod install,后续构建时该警告会消失。

方案2:确保Fastlane构建前执行Pod安装

在Fastfile的构建lane中加入cocoapods步骤,确保上述Podfile修改生效:

lane :build_ios do
  # 执行pod install,应用Podfile中的post_install配置
  cocoapods(
    podfile: "ios/Podfile",
    clean_install: false # 根据项目需求调整是否clean install
  )

  # 后续的构建步骤,例如:
  # build_app(
  #   workspace: "ios/dxp.xcworkspace",
  #   scheme: "dxp"
  # )
end

原理说明

Xcode 15+对构建脚本阶段的输出检查更为严格,而react-native-firebase默认生成的[RNFB] Core Configuration脚本未配置输出文件,同时该脚本的配置会被每次pod install重置,因此手动修改Xcode设置无法持久生效。通过Podfile的post_install钩子可以在每次pod安装后自动调整脚本阶段的配置,彻底解决警告问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.17 16:02:37