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

React Native升级后执行pod install报Unknown configuration whitelisted错误

React Native升级后pod install报错解决:Unknown configuration whitelisted: .

问题场景

升级React Native版本后,在iOS目录执行pod install时触发如下错误:

Auto-linking React Native modules for target <projectname>: RNScreens, RNVectorIcons, and react-native-safe-area-context
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
Analyzing dependencies
Fetching podspec for DoubleConversion from ../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec
[Codegen] Found FBReactNativeSpec
/Users/belgin/Documents/Apps//node_modules/react-native/scripts/react_native_pods_utils/script_phases.rb:50: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
/Users/belgin/Documents/Apps//node_modules/react-native/scripts/react_native_pods_utils/script_phases.rb:50: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.
Fetching podspec for RCT-Folly from ../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec
Fetching podspec for boost from ../node_modules/react-native/third-party-podspecs/boost.podspec
Fetching podspec for glog from ../node_modules/react-native/third-party-podspecs/glog.podspec
[!] Unknown configuration whitelisted: . CocoaPods found debug and release, did you mean one of these?

当前使用的Podfile内容:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'
install! 'cocoapods', :deterministic_uuids => false

target '<ProjectName>' do
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target '<ProjectName>' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  use_flipper!()

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

解决方案

1. 清理CocoaPods环境与依赖缓存

进入项目的ios目录,依次执行以下命令:

pod deintegrate
rm -rf Podfile.lock
rm -rf ../node_modules
npm install  # 或 yarn install
pod install

2. 修复Podfile的嵌套Target命名冲突

Podfile中主Target与内部测试Target使用了相同名称,可能导致配置解析异常。修改内部Target名称为唯一值,例如:

target '<ProjectName>' do
  # ... 原有代码 ...

  target '<ProjectName>Tests' do
    inherit! :complete
    # Pods for testing
  end

  # ... 原有代码 ...
end

3. 升级CocoaPods版本

旧版CocoaPods与新版React Native可能存在兼容性问题,执行命令升级:

sudo gem install cocoapods

4. 检查Xcode项目配置

打开Xcode,进入项目的Build Settings -> Configurations,确认仅存在Debug和Release两个有效配置,删除空的或无效的自定义配置。

5. 排查第三方依赖问题

临时禁用某个自动链接的第三方模块(如RNVectorIcons、RNScreens),手动配置后重新执行pod install,逐步定位是否为某一依赖的配置异常导致。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.14 03:30:50