尝试为 iOS 运行或构建 Flutter 项目时出错
Posted
技术标签:
【中文标题】尝试为 iOS 运行或构建 Flutter 项目时出错【英文标题】:Error when trying to run or build Flutter project for iOS 【发布时间】:2021-01-22 19:28:12 【问题描述】:所以基本上我可以运行其他项目,我可以在 android 上运行这个,但是当我想为 ios 运行或构建它时,我收到以下错误消息。这也不是项目相关的问题,我的同事可以很好地运行它。我尝试了所有可能的在线解决方案,将安装后的东西添加到 Podfile,尝试在 Xcode 中更改为“旧版构建系统”但同样的错误,尝试重新安装 Pod、CocoaPods,甚至切换到 beta。不知道该怎么办了。
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Running pod install... 23.5s
Running Xcode build...
Xcode build done. 28.5s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
/Users/djordje/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/ios/Classes/strategies/PhotoPermissionStrategy.m:39:13:
warning: enumeration value 'PHAuthorizationStatusLimited' not handled in switch [-Wswitch]
switch (authorizationStatus)
^
/Users/djordje/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.0.1+1/ios/Classes/strategies/PhotoPermissionStrategy.m:39:13:
note: add missing switch cases
switch (authorizationStatus)
^
1 warning generated.
/Users/djordje/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/image_downloader-0.19.2/ios/Classes/SwiftImageDownloaderPlugin.swift:37:17: error:
switch must be exhaustive
switch status
^
/Users/djordje/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/image_downloader-0.19.2/ios/Classes/SwiftImageDownloaderPlugin.swift:37:17: note: do
you want to add missing cases?
switch status
^
/Users/djordje/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inapp_purchase-2.2.0/ios/Classes/FlutterInappPurchasePlugin.m:45:52:
warning: assigning to 'id<IAPPromotionObserverDelegate>' from incompatible type 'FlutterInappPurchasePlugin *__strong'
[IAPPromotionObserver sharedObserver].delegate = self;
^ ~~~~
/Users/djordje/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inapp_purchase-2.2.0/ios/Classes/FlutterInappPurchasePlugin.m:200:79:
warning: implicit conversion loses integer precision: 'SKPaymentTransactionState' (aka 'enum SKPaymentTransactionState') to 'int' [-Wshorten-64-to-32]
[NSNumber numberWithInt: item.transactionState], @"transactionStateIOS",
~ ^~~~~~~~~~~~~~~~~~~~~
/Users/djordje/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inapp_purchase-2.2.0/ios/Classes/FlutterInappPurchasePlugin.m:586:71:
warning: implicit conversion loses integer precision: 'SKPaymentTransactionState' (aka 'enum SKPaymentTransactionState') to 'int' [-Wshorten-64-to-32]
[NSNumber numberWithInt: transaction.transactionState], @"transactionStateIOS",
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings generated.
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'abseil' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'image_downloader' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'gRPC-C++' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'gRPC-Core' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'gRPC-C++-gRPCCertificates-Cpp' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'Protobuf' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'PromisesObjC' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'GoogleUtilities' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'GoogleDataTransport' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'GTMSessionFetcher' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'GTMAppAuth' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseMessaging' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseStorage' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseInstanceID' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseInstallations' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseFirestore' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseDynamicLinks' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseCore' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseAuth' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseCoreDiagnostics' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'BoringSSL-GRPC' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FBSDKLoginKit' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'AppAuth' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'path_provider' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'package_info' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'scrollable_bottom_sheet' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'permission_handler' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'url_launcher' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'shared_preferences' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'nanopb' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'map_launcher' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'location_permissions' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'location' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'maps_launcher' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'leveldb-library' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'google_sign_in' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'image_picker' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'google_maps_flutter' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'geolocator' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'geocoder' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'flutter_inapp_purchase' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'flutter_email_sender' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'flutter_appavailability' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'firebase_storage' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'firebase_messaging' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'firebase_dynamic_links' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'firebase_auth' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'firebase_core' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'device_info' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'contacts_service' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'cloud_firestore' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'apple_sign_in' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FBSDKCoreKit' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'GoogleAppMeasurement' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'GoogleSignIn' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'FirebaseAnalytics' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'Flutter' from project 'Pods')
warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to
14.0.99. (in target 'Firebase' from project 'Pods')
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max.
【问题讨论】:
通过安装最新版本的 cocoapods 然后pod install
修复了我的问题,同时添加了一些flutter clean
【参考方案1】:
与Flutter project - XCode build failed相关
首先,确认你在flutter channel stable,然后flutter升级
那么,什么对我有用:
sudo gem uninstall cocoapods;
sudo gem install cocoapods;
flutter clean
flutter pub get
cd ios; pod install; cd ..;
其他可能有帮助的命令
cd ios; pod install --repo-update; cd ..;
//deactivate rvm
rvm use system
其他想法:
删除整个 repo 和 git clone 删除派生数据(检查 Google) 删除 Podspec.lock 和 Gemfile.lock【讨论】:
以上是关于尝试为 iOS 运行或构建 Flutter 项目时出错的主要内容,如果未能解决你的问题,请参考以下文章
Flutter 无法仅在物理 iOs 设备中构建和运行 iOS 应用程序
运行 pod install 时 Flutter iOS 构建失败
当我运行 flutter run 时,Flutter iOS 构建失败