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

M1芯片设备上如何配置空安全版本Firebase开发环境?

编辑:当前问题已解决,仅需使用最新版本即可

我测试了最新版本的Firebase,遇到如下报错:CocoaPods could not find compatible versions for pod "Firebase/Firestore":

# 空安全版本 # 原版本无法运行 # 已解决
firebase_core: ^1.5.0   # 已解决,升级到^1.6.0即可
firebase_auth: ^3.0.2   # 已解决,升级到^3.1.0即可
cloud_firestore: ^2.5.0 # 已解决,升级到^2.5.1即可
                        # 已解决,firebase_storage升级到^10.0.3即可

# 非空安全版本 # 可正常运行
# firebase_core: ^0.4.0+9
# firebase_auth: ^0.14.0+5
# cloud_firestore: ^0.12.9+5

运行环境

  • ➜ ios git:(master) ✗ ruby --version ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20]
  • ➜ ios git:(master) ✗ gem --version 3.0.3

已尝试操作

  1. 清理Flutter项目缓存
➜  flash-chat-flutter git:(master) ✗ flutter clean
Cleaning Xcode workspace...                                         4.4s
....
  1. 清理全部Pod缓存
➜  ios git:(master) ✗ pod cache clean --all
  1. 移除项目中CocoaPods相关配置
➜  ios git:(master) ✗ pod deintegrate
Deintegrating `Runner.xcodeproj`
Deleted 1 'Check Pods Manifest.lock' build phases.
....
Deleted 1 empty `Frameworks` groups from project.
Removing `Pods` directory.

Project has been deintegrated. No traces of CocoaPods left in project.
Note: The workspace referencing the Pods project still remains.
  1. Apple Silicon设备适配安装ffi依赖
➜  ios git:(master) ✗ sudo arch -x86_64 gem install ffi
Password:
Building native extensions. This could take a while...
Successfully installed ffi-1.15.3
Parsing documentation for ffi-1.15.3
Done installing documentation for ffi after 3 seconds
1 gem installed
  1. 安装预发布版本CocoaPods
➜  ios git:(master) ✗ sudo gem install cocoapods --pre
....
Fetching xcodeproj-1.21.0.gem
....
Successfully installed cocoapods-1.11.0.rc.1
Parsing documentation for addressable-2.8.0
Installing ri documentation for addressable-2.8.0
....
Done installing documentation for addressable, cocoapods-core, molinillo, xcodeproj, cocoapods after 2 seconds
5 gems installed

我在以下步骤遇到了问题...

  1. 执行pod update报错
➜  ios git:(master) ✗ arch -x86_64 pod update
Update all pods
Updating local specs repositories
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '8.5.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '8.5.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '8.5.0' defined in 'firebase_core'
[!] CocoaPods could not find compatible versions for pod "cloud_firestore":
  In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)

Specs satisfying the `cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)` dependency were found, but they required a higher minimum deployment target.

[!] Automatically assigning platform `iOS` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile.
  1. 执行pod install报错
➜  ios git:(master) ✗ arch -x86_64 pod install
Analyzing dependencies
cloud_firestore: Using Firebase SDK version '8.5.0' defined in 'firebase_core'
firebase_auth: Using Firebase SDK version '8.5.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '8.5.0' defined in 'firebase_core'
[!] CocoaPods could not find compatible versions for pod "Firebase/Firestore":
  In snapshot (Podfile.lock):
    Firebase/Firestore (= 6.34.0, ~> 6.0)

  In Podfile:
    cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) was resolved to 2.5.0, which depends on
      Firebase/Firestore (= 8.5.0)


You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * changed the constraints of dependency `Firebase/Firestore` inside your development pod `cloud_firestore`.
   You should run `pod update Firebase/Firestore` to apply changes you've made.

[!] Automatically assigning platform `iOS` with version `8.0` on target `Runner` because no platform was specified.

我参照了Apple Silicon设备运行CocoaPods的适配教程操作,仅非空安全版本可正常运行。


解决方案

该问题由依赖版本不匹配、iOS最低部署版本过低两个原因导致,按以下步骤操作即可解决:

  1. 升级Flutter侧Firebase相关依赖到修复版本,替换pubspec.yaml中对应配置:
firebase_core: ^1.6.0
firebase_auth: ^3.1.0
cloud_firestore: ^2.5.1
firebase_storage: ^10.0.3
  1. 调整iOS侧最低部署版本:打开项目ios目录下的Podfile,取消首行# platform :ios, '9.0'的注释,将版本号修改为12.0(新版Firebase iOS SDK要求最低支持iOS 12.0及以上),修改后内容如下:
platform :ios, '12.0'
  1. 重新执行依赖安装:
flutter clean
cd ios
pod deintegrate
pod cache clean --all
arch -x86_64 pod install --repo-update

操作完成后重新运行项目即可正常编译。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.06 07:15:04