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

React Native 0.73.6 iOS推送通知配置异常,编译报错退出码65

解决iOS推送配置中xcodebuild退出码65、找不到FirebaseCoreInternal.modulemap的问题

以下是针对性的排查和修复步骤:

1. 彻底清理缓存与Pod依赖

先清除旧的Pod缓存和构建产物,避免依赖冲突:

cd ios
# 删除Pod相关文件
rm -rf Pods Podfile.lock
# 删除Xcode衍生数据
rm -rf ~/Library/Developer/Xcode/DerivedData
# 解除Pod关联并清理
pod deintegrate
pod clean

2. 修正Podfile配置

确保Podfile满足React Native Firebase 20.x的版本要求,并且配置静态框架链接(Firebase 10+需要):

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

# React Native Firebase 20.x要求最低iOS版本13.0
platform :ios, '13.0'

target '你的App名称' do
  config = use_native_modules!

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => true,
    :fabric_enabled => false,
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  # 手动指定Firebase版本,确保与RN Firebase 20.x兼容
  pod 'Firebase/CoreInternal', '~> 10.22.0'
  pod 'Firebase/Messaging', '~> 10.22.0'

  target '你的App名称Tests' do
    inherit! :complete
  end

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

    # 为Firebase添加框架搜索路径与编译配置
    installer.pods_project.targets.each do |target|
      if target.name.start_with?('Firebase')
        target.build_configurations.each do |config|
          config.build_settings['ENABLE_BITCODE'] = 'NO'
          config.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= []
          config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '$(inherited)'
          config.build_settings['FRAMEWORK_SEARCH_PATHS'] << '${PODS_ROOT}/FirebaseCoreInternal'
        end
      end
    end
  end
end

3. 重新安装Pods

根据芯片架构选择对应命令:

  • Intel芯片:
    pod install --repo-update
    
  • M1/M2芯片:
    arch -x86_64 pod install --repo-update
    

4. 检查Xcode项目配置

打开项目的.xcworkspace文件(不要用.xcodeproj),进入Build Settings:

  • 搜索Framework Search Paths,确认${PODS_ROOT}/FirebaseCoreInternal已添加
  • 搜索Header Search Paths,添加${PODS_ROOT}/FirebaseCoreInternal/Headers
  • 清理项目(Cmd+Shift+K)后重新编译

5. 验证AppDelegate.m配置

确保Firebase初始化和推送相关代码正确:

#import <Firebase.h>
#import <FirebaseMessaging.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  // 初始化Firebase
  if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
  // 其他原有代码...
  return YES;
}

// 推送相关方法示例
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  [FIRMessaging messaging].APNSToken = deviceToken;
  // 其他推送逻辑...
}

额外注意点

  • React Native Firebase 20.x要求RN版本至少为0.72.x,确认你的RN版本符合要求
  • 模拟器无法接收APNS推送,编译问题解决后需用真机测试推送功能
  • 检查Podfile.lock,确保所有Firebase相关依赖版本一致,无冲突

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 13:23:24