无法在 iOS 设备(模拟器)上运行我的 flutter 应用程序,并且失败并显示以下错误日志,尽管它在 Android 上运行良好。一切都工作正常,直到我尝试添加 MacOS 构建,该构建已更改回滚,但相同的错误仍然存在。
我还卸载并重新安装了
cocopods
,清理了缓存,flutter clean,pod安装,pod [repo]更新,但似乎没有任何效果,并且在我的Mac Book pro M2(苹果芯片)上总是显示相同的错误。无论如何,在具有相同代码库的 Intel 芯片 Macbook 上运行良好,所以肯定与苹果芯片架构和/或一些本地缓存有关?
运行控制台日志输出(错误):
Launching lib/main.dart on iPhone 14 Plus (6.7-inch) in debug mode...
Running pod install...
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
Finding Podfile changes
..
- google_mobile_ads
- google_sign_in_ios
...
Fetching external sources
-> Fetching podspec for `Flutter` from `Flutter`
-> Fetching podspec for `app_tracking_transparency` from `.symlinks/plugins/app_tracking_transparency/ios`
-> Fetching podspec for `file_picker` from `.symlinks/plugins/file_picker/ios`
-> Fetching podspec for `flutter_native_splash` from `.symlinks/plugins/flutter_native_splash/ios`
-> Fetching podspec for `google_mobile_ads` from `.symlinks/plugins/google_mobile_ads/ios`
-> Fetching podspec for `google_sign_in_ios` from `.symlinks/plugins/google_sign_in_ios/darwin`
[!] No podspec found for `google_sign_in_ios` in `.symlinks/plugins/google_sign_in_ios/darwin`
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/external_sources/path_source.rb:14:in `block in fetch'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/external_sources/path_source.rb:11:in `fetch'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:997:in `fetch_external_source'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:976:in `block (2 levels) in fetch_external_sources'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:975:in `each'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:975:in `block in fetch_external_sources'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:974:in `fetch_external_sources'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:118:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:422:in `analyze'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:162:in `install!'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/bin/pod:25:in `load'
/opt/homebrew/Cellar/cocoapods/1.15.2/libexec/bin/pod:25:in `<main>'
Error output from CocoaPods:
↳
[!] Automatically assigning platform `iOS` with version `15.2` 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`.
Error running pod install
Error launching application on iPhone 14 Plus (6.7-inch).
我的 pubspec.yaml 文件包含:
# versions available, run `flutter pub outdated`.
version: 1.0.0+1
environment:
sdk: '>=3.2.0 <4.0.0'
dependencies:
flutter:
sdk: flutter
#...
# other dependencies.
#...
googleapis: ^11.4.0
google_sign_in: ^6.2.1
extension_google_sign_in_as_googleapis_auth: ^2.0.11
已解决此问题,问题出在
.pub-cache
文件夹中。
检查了我的 flutter 项目根文件夹中的
.flutter-plugins-dependencies
和 .flutter-plugins
文件后,了解到插件正在我的用户主目录中兑现,并且 ~/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.4.bkp/darwin/
是空的。如下:
$ cd ~/.pub-cache/hosted/pub.dev
$ ls -l | grep 'google_sign_in_ios'
drwx------ 12 vijay staff 384 29 Oct 19:38 google_sign_in_ios-5.6.4
drwx------@ 12 vijay staff 384 9 Apr 02:34 google_sign_in_ios-5.6.5
drwx------@ 12 vijay staff 384 9 Apr 02:34 google_sign_in_ios-5.7.4
$ ls google_sign_in_ios-5.7.4.bkp/darwin/
简单地重命名/删除
google_sign_in_ios-5.7.4
,如下所示:
$ mv google_sign_in_ios-5.7.4 google_sign_in_ios-5.7.4.bkp
之后重新运行 flutter 应用程序,花了一分钟时间下载了一些东西(不确定在哪里),并且应用程序成功加载到我的 iOS 模拟器上。
只是为了确定这个简单的修复是否真的是解决方案(对于困扰我好几天的问题,因为我简直不敢相信),我做了
mv google_sign_in_ios-5.7.4.bkp google_sign_in_ios-5.7.4
并停止并重新运行该应用程序。正如预期的那样,它失败了,并显示相同的原始错误日志。
现在我应用了上述修复,宾果游戏成功了。希望它对某人有帮助。