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

SwiftUI+Firebase iOS应用运行数秒后崩溃问题求助

解决M1 Mac上Firebase+CocoaPods导致的应用崩溃问题
  • 清理CocoaPods缓存并重新安装
    这个错误大概率是依赖库安装不完整、版本冲突或M1架构兼容性问题导致的,按以下步骤操作:

    1. 删除项目根目录下的Pods文件夹和Podfile.lock文件
    2. 打开终端进入项目目录,依次执行命令:
      pod deintegrate
      pod cache clean --all
      pod install --repo-update
      
    3. 若问题仍存在,在Podfile末尾添加架构兼容配置后重新执行pod install:
      post_install do |installer|
        installer.pods_project.targets.each do |target|
          target.build_configurations.each do |config|
            config.build_settings['ARCHS[sdk=iphonesimulator*]'] = 'arm64 x86_64'
          end
        end
      end
      
  • 统一Firebase依赖版本
    确保Podfile中所有Firebase相关库使用相同版本,避免版本混合引发方法签名不匹配:

    pod 'Firebase/Core', '10.15.0'
    pod 'Firebase/Auth', '10.15.0'
    # 其他Firebase组件保持与上面一致的版本号
    
  • 检查Xcode架构设置

    1. 打开项目Target的Build Settings
    2. 搜索Excluded Architectures,确认模拟器(iphonesimulator)未排除arm64架构
    3. 检查Valid Architectures,确保包含arm64和x86_64
  • 重置模拟器与Xcode缓存

    1. 关闭Xcode和模拟器
    2. 执行命令清理Xcode衍生数据:
      rm -rf ~/Library/Developer/Xcode/DerivedData
      
    3. 打开模拟器,选择Device > Erase All Content and Settings,之后重新运行项目

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 00:18:31