React Native 0.72.3中RCTAppDelegate.h文件缺失问题求助
解决React Native中「RCTAppDelegate.h file not found」错误(Xcode 14.3.1 + React Native 0.72.3)
我是React Native新手,运行现有项目时遇到「RCTAppDelegate.h file not found」错误,试过谷歌上所有解决方案都无效。我的环境是Xcode 14.3.1、React Native 0.72.3,以下是我的Podfile内容,希望能解决让Xcode找到该文件的问题:
# Resolve react_native_pods.rb with node to allow for hoisting require Pod::Executable.execute_command('node', ['-p', 'require.resolve( "react-native/scripts/react_native_pods.rb", {paths: [process.argv[1]]}, )', __dir__]).strip platform :ios, '14.0' source 'https://github.com/CocoaPods/Specs.git' prepare_react_native_project! # If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. # because `react-native-flipper` depends on (FlipperKit,...) that will be excluded # # To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` # ```js # module.exports = { # dependencies: { # ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), # ``` flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym end target 'AuthCoreWalletDemo' do config = use_native_modules! use_frameworks! :linkage => :static # Flags change depending on the env values. flags = get_default_flags() use_react_native!( :path => config[:reactNativePath], # Hermes is now enabled by default. Disable by setting this flag to false. :hermes_enabled => false,#flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], # Enables Flipper. # # Note that if you have use_frameworks! enabled, Flipper will not work and # you should disable the next line. # :flipper_configuration => flipper_config, # An absolute path to your application root. :app_path => "#{Pod::Config.instance.installation_root}/.." ) pod 'AuthCoreAdapter', '0.1.9' pod 'ParticleAuthCore', '0.1.9' pod 'ParticleMPCCore', '0.1.9' pod 'Thresh', '0.1.9' pod 'ParticleWalletGUI', '1.0.2' pod 'ParticleWalletAPI', '1.0.2' pod 'ParticleNetworkBase', '1.0.2' pod 'ParticleAuthService', '1.0.2' pod 'ParticleWalletConnect', '1.0.2' pod 'ParticleBiconomy', '1.0.2' pod 'ParticleConnect', '0.2.8' pod 'ConnectWalletConnectAdapter', '0.2.8' pod 'ConnectEVMAdapter', '0.2.8' pod 'ConnectSolanaAdapter', '0.2.8' pod 'ConnectPhantomAdapter', '0.2.8' pod 'ConnectCommon', '0.2.8' pod 'ParticleAuthAdapter', '0.2.8' pod 'SkeletonView', :git => 'https://github.com/SunZhiC/SkeletonView.git', :branch => 'main' pod 'SwiftMessages', :git => 'https://github.com/SunZhiC/SwiftMessages', :branch => 'master' target 'AuthCoreWalletDemoTests' do inherit! :complete # Pods for testing end post_install do |installer| # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 react_native_post_install( installer, config[:reactNativePath], :mac_catalyst_enabled => false ) __apply_Xcode_12_5_M1_post_install_workaround(installer) installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES' end end # This is necessary for Xcode 14, because it signs resource bundles by default # when building for devices. installer.target_installation_results.pod_target_installation_results .each do |pod_name, target_installation_result| target_installation_result.resource_bundle_targets.each do |resource_bundle_target| resource_bundle_target.build_configurations.each do |config| config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO' end end end installer.generated_projects.each do |project| project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0' end end end installer.pods_project.build_configurations.each do |config| config.build_settings['VALID_ARCHS'] = 'arm64, arm64e, x86_64' end end end
针对性修复步骤
1. 统一use_frameworks!配置
Podfile在全局和target内重复设置use_frameworks!可能导致依赖链接冲突,修改全局逻辑并移除target内的重复设置:
# 替换原来的linkage代码 linkage = ENV['USE_FRAMEWORKS'] || 'static' Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym target 'AuthCoreWalletDemo' do config = use_native_modules! # 移除这一行:use_frameworks! :linkage => :static # 其他代码保持不变 end
2. 确认React Native路径指向
如果自动获取的路径有问题,手动指定use_react_native!中的:path:
use_react_native!( :path => "../node_modules/react-native", # 根据项目目录层级调整 # 其他参数保持不变 )
3. 彻底清理缓存并重装依赖
执行以下命令:
# 清理Node依赖 rm -rf node_modules rm package-lock.json yarn.lock npm install # 清理iOS依赖 cd ios pod deintegrate pod cache clean --all pod install
关闭Xcode后,按Cmd+Shift+Option+K清除Xcode缓存,再打开项目的.xcworkspace文件(不要打开.xcodeproj)。
4. 检查Xcode头文件搜索路径
在Xcode中选中主targetAuthCoreWalletDemo,进入Build Settings,搜索Header Search Paths,添加以下路径并设置为recursive:
$(SRCROOT)/../node_modules/react-native/React$(SRCROOT)/../node_modules/react-native/ReactCommon
5. 移除冗余的部署目标配置
post_install脚本中重复设置的IPHONEOS_DEPLOYMENT_TARGET和全局配置冲突,移除这段代码:
# 移除post_install中的这段 installer.generated_projects.each do |project| project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0' end end end
内容的提问来源于stack exchange,提问作者user22408481
相关产品推荐
相关产品推荐

