Flutter:在调试模式下构建时运行pod install需要很长时间

15

我使用iPhone 11 iOS-14设备和模拟器,已经删除了我的Flutter应用程序的Podfile和Podlock,并尝试以调试模式重新构建该应用程序。 我正在使用最新的Firebase依赖项,包括cloud_firestore:^0.14.1依赖项,然后它在pod install处卡住,花费的时间太长了,已经超过了半个小时。

我想知道是否应该等待更长时间,还是Firebase依赖项出现了问题?

7个回答

29

当你删除Podfile.lock文件时,pod install并不会卡住,它将重新下载所有的pod依赖,这需要一定时间。完成后,它将创建一个新的Podfile.lock文件。

我有一个包含20多个Flutter依赖项的项目,其中Firebase依赖项是最复杂的。


我有19个依赖项,其中包括大部分Firebase.. 我希望它能够结束,使用旧的依赖项特别是Firebase的话不会花费这么长时间。 - azheen
4
预计当我错误地删除 podfile.lock 时,需要等待大约3/4个小时,只需让它完成工作,喝杯咖啡,玩些游戏,在回来时它会成功。 - Kohls
请将以下与编程有关的内容从英语翻译成中文。只返回已翻译的文本:如果您确认这个翻译有效,请不要忘记标记为已接受的答案。 - Kohls
不用担心,我会的,现在还在等待。 - azheen
1
是的,我可以确认,它不会卡住。我最终运行应用程序花了将近1个小时。太疯狂了。 - Alexa289

3
有时候,执行 'pod install' 命令似乎需要很长时间,但实际上它正在后台下载依赖项。
请尝试查看 Activity Monitor 网络选项卡以确认是否正在下载数据。
在我的情况下,我的 pod 依赖于 Firebase pods,因此完成我的依赖项大约需要 10 分钟。

我们在哪里可以激活Activity Monitor的网络选项卡? - Ekim Cem Ülger

1

官方文档推荐的方式如下:

可选:通过包含预编译的框架来提高 iOS 和 macOS 的构建时间。 目前,Firestore SDK for iOS 依赖于可能需要在 Xcode 中构建超过5分钟的代码。为了显著减少构建时间,您可以通过在 Podfile 中的目标“Runner”块中添加此行来使用预编译版本:

target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.15.0'
  # ...
end

此外,请确保您已将 CocoaPods 升级至 1.9.1 或更高版本:
gem install cocoapods

1

如果你花了20-30分钟的时间执行"pod install"命令,但它似乎一直卡着不动(可能是安装Firebase依赖项,然后在不同的机器上运行同一项目)。那么还有其他解决方法。

清除缓存并获取您的依赖项

flutter clean
flutter pub get

从终端导航到您的 iOS 文件夹

cd ios

移除主干

pod repo remove trunk

如果您当前的安装是在Intel芯片的Mac上运行以下代码
pod install --repo-update

如果您的安装在M1芯片设备上,请先安装ffi

sudo arch -x86_64 gem install ffi

然后更新POD

arch -x86_64 pod install --repo-update

现在清理并获取依赖项

flutter clean
flutter pub get

如果您遇到类似以下的错误
[!] 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 `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

然后前往 Podfile,取消注释 platmform:ios 行并更新它。
platform :ios, '12.0'

现在重新运行命令

arch -x86_64 pod install --repo-update

别忘了用flutter clean清理pub缓存


0

检查您的Xcode是否是最新版本。 更新我的Xcode已经解决了我的问题。

我尝试了所有上述解决方案,但都没有起作用。 只有更新Xcode才有效。


0
在 Podfile 中的 target 'Runner' do 下添加以下行:

pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '6.33.0'

然后在 IOS 中执行以下操作:

flutter clean
pod repo update

更多信息请参见:https://github.com/FirebaseExtended/flutterfire/issues/2751


0

enter image description here

之前的评论是正确的,你只需要在“运行pod install…”和“运行Xcode构建…”中等待即可。我附上了屏幕截图,你可以找到我等了多久:

  1. 运行pod install… 687.5秒(11.4分钟)
  2. 运行Xcode构建… 1421.2秒(23.6分钟)

我希望这对像证明一样的人有所帮助))

我没有添加这个:

target 'Runner' do
  pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '8.15.0'
  # ...
end

也许会更快,还有人评论说:
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接