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

React Native中Pod install完成后陷入无限循环问题求助

Pod install 无限循环打印React-Core及xcconfig路径问题

问题现象

运行pod install时,所有pod安装完成后程序陷入无限循环,重复打印以下内容:

React-Core

/path/project/ios/Pods/Target Support Files/Pods-project/Pods-project.release.xcconfig

/path/project/ios/Pods/Target Support Files/Pods-project/Pods-project.debug.xcconfig

/path/project/ios/Pods/Target Support Files/Pods-project-projectTests/Pods-project-projectTests.release.xcconfig

/path/project/ios/Pods/Target Support Files/Pods-project-projectTests/Pods-project-projectTests.debug.xcconfig

操作背景

此前项目运行正常,执行以下操作后出现该问题:

  • 执行yarn cache clean清理缓存
  • 删除pods目录及Podfile.lock文件
  • 运行pod install

我的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, '12.0'

use_frameworks!
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if pod.name.start_with?('RNFB') || pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
      def pod.build_type;
        Pod::BuildType.static_library # >= 1.9
      end
    end
  end
end

target 'project' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

    # react-native-permissions permission handlers
    permissions_path = '../node_modules/react-native-permissions/ios'

    pod 'Permission-Camera', :path => "#{permissions_path}/Camera/Permission-Camera.podspec"
    pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary/Permission-MediaLibrary.podspec"
    pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications/Permission-Notifications.podspec"
    pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways/Permission-LocationAlways.podspec"
    pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse/Permission-LocationWhenInUse.podspec"

    pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
    # pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
    
    
    # Add the Firebase pod for Google Analytics
    pod 'Firebase/Analytics'

    # For Analytics without IDFA collection capability, use this pod instead
    # pod ‘Firebase/AnalyticsWithoutAdIdSupport’

    # Add the pods for any other Firebase products you want to use in your app
    # For example, to use Firebase Authentication and Cloud Firestore
    pod 'Firebase/Auth'
    pod 'Firebase/Firestore'
    
  pod 'RNSVG', :path => '../node_modules/react-native-svg'

  #pod 'react-native-network-info', :path => '../node_modules/react-native-network-info'

  pod 'react-native-camera', :path => '../node_modules/react-native-camera'

  pod 'RNPermissions', :path => '../node_modules/react-native-permissions'

  pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'

  target 'project' 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|
    installer.pods_project.targets.each do |target|
    react_native_post_install(installer)
    target.build_configurations.each do |config|
     # some older pods don't support some architectures, anything over iOS 11 resolves that
       config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
    end
  end
end

解决方法

1. 修复post_install循环逻辑

你的post_install钩子中,react_native_post_install(installer)被放在了installer.pods_project.targets.each循环内部,这会导致每次遍历target时都重复执行React Native的后置安装逻辑,触发xcconfig文件的重复生成,进而引发无限循环。

修改post_install代码,将react_native_post_install(installer)移到循环外部:

post_install do |installer|
  react_native_post_install(installer)
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # some older pods don't support some architectures, anything over iOS 11 resolves that
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end

2. 彻底清理后重新安装

  1. 终止当前卡住的pod install进程
  2. 执行以下命令清理残留文件与缓存:
rm -rf ios/Pods ios/Podfile.lock ios/build
yarn cache clean
cd ios && pod deintegrate && pod repo update
  1. 重新运行pod install

3. 排查动态/静态库冲突

你同时使用了use_frameworks!(默认动态库)和强制部分pod以静态库构建的逻辑,可能引发依赖冲突:

  • 若无需动态库,直接移除use_frameworks!
  • 若需要统一静态库构建,将use_frameworks!替换为use_frameworks! :linkage => :static(需CocoaPods 1.10及以上版本支持)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.26 00:15:38