为啥 Flutter iOS 构建失败?
Posted
技术标签:
【中文标题】为啥 Flutter iOS 构建失败?【英文标题】:Why Flutter iOS build failed?为什么 Flutter iOS 构建失败? 【发布时间】:2021-04-30 06:57:42 【问题描述】:我已经成功构建了一个 android 应用程序,现在我正在使用 Flutter 构建 ios 应用程序。这是第一次的所有文件但是重新启动我的vscode后我收到了这个错误。谁能帮我解决以下问题?我在下面包含了 Pod 文件代码和调试输出。
#platform :ios, '9.0'
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner',
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#generated_xcode_build_settings_path must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #generated_xcode_build_settings_path. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end
调试输出
Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
lib/main.dart:1
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
Finding Podfile changes
A store_redirect
A stripe_payment
- Flutter
- cloud_firestore
- connectivity
- firebase_analytics
- firebase_auth
- firebase_core
- firebase_messaging
- firebase_storage
- flutter_facebook_login
- google_sign_in
- image_picker
- purchases_flutter
- shared_preferences
- url_launcher
Fetching external sources
-> Fetching podspec for `Flutter` from `Flutter`
-> Fetching podspec for `cloud_firestore` from `.symlinks/plugins/cloud_firestore/ios`
-> Fetching podspec for `connectivity` from `.symlinks/plugins/connectivity/ios`
-> Fetching podspec for `firebase_analytics` from `.symlinks/plugins/firebase_analytics/ios`
-> Fetching podspec for `firebase_auth` from `.symlinks/plugins/firebase_auth/ios`
-> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
-> Fetching podspec for `firebase_messaging` from `.symlinks/plugins/firebase_messaging/ios`
-> Fetching podspec for `firebase_storage` from `.symlinks/plugins/firebase_storage/ios`
-> Fetching podspec for `flutter_facebook_login` from `.symlinks/plugins/flutter_facebook_login/ios`
-> Fetching podspec for `google_sign_in` from `.symlinks/plugins/google_sign_in/ios`
-> Fetching podspec for `image_picker` from `.symlinks/plugins/image_picker/ios`
-> Fetching podspec for `purchases_flutter` from `.symlinks/plugins/purchases_flutter/ios`
-> Fetching podspec for `shared_preferences` from `.symlinks/plugins/shared_preferences/ios`
-> Fetching podspec for `store_redirect` from `.symlinks/plugins/store_redirect/ios`
-> Fetching podspec for `stripe_payment` from `.symlinks/plugins/stripe_payment/ios`
-> Fetching podspec for `url_launcher` from `.symlinks/plugins/url_launcher/ios`
Resolving dependencies of `Podfile`
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
CDN: trunk Relative path: all_pods_versions_0_3_5.txt exists! Returning local because checking is only perfomed in repo update
CDN: trunk Relative path: Specs/0/3/5/Firebase/7.4.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
2
CDN: trunk Relative path: Specs/0/3/5/Firebase/6.34.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
CDN: trunk Relative path: all_pods_versions_c_7_9.txt exists! Returning local because checking is only perfomed in repo update
CDN: trunk Relative path: Specs/c/7/9/Reachability/3.2/Reachability.podspec.json exists! Returning local because checking is only perfomed in repo update
4
CDN: trunk Relative path: Specs/0/3/5/Firebase/6.34.0/Firebase.podspec.json exists! Returning local because checking is only perfomed in repo update
CDN: trunk Relative path: all_pods_versions_9_b_5.txt exists! Returning local because checking is only perfomed in repo update
CDN: trunk Relative path: Specs/9/b/5/FBSDKCoreKit/9.0.0/FBSDKCoreKit.podspec.json exists! Returning local because checking is only perfomed in repo update
CDN: trunk Relative path: all_pods_versions_b_3_c.txt exists! Returning local because checking is only perfomed in repo update
CDN: trunk Relative path: Specs/b/3/c/FBSDKLoginKit/9.0.0/FBSDKLoginKit.podspec.json exists! Returning local because checking is only perfomed in repo update
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolution.rb:182:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.6.6/lib/molinillo/resolver.rb:43:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/resolver.rb:94:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1074:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:1072:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer/analyzer.rb:124:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:414:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:239:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:238:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/installer.rb:160:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.10.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
Error output from CocoaPods:
↳
[!] 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`.
Error running pod install
Error launching application on iPhone 12 Pro Max.
Exited (sigterm)
【问题讨论】:
这是构建的完整输出? @fartem 很抱歉没有提供完整的调试代码。现已编辑。 【参考方案1】:根据错误消息,您的 Podfile 中缺少 platform
属性。
要修复它,请编辑您应用的 Podfile,并添加以下行:
platform :ios, '10.0'
您也可以定义不同的 iOS 版本。
【讨论】:
【参考方案2】:试试这个
post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
【讨论】:
以上是关于为啥 Flutter iOS 构建失败?的主要内容,如果未能解决你的问题,请参考以下文章
为啥 Flutter 构建失败并出现错误无法解析配置“:app:debugRuntimeClasspath”的所有文件
如何减少 Flutter 中 IOS 构建的 .ipa 文件大小?
为啥flutter build ios --obfuscate --split-debug-info= 失败并出现警告,但flutter build ios 有效?
Flutter 构建在 iOS 上失败,但在 android 上工作
为啥我在为 Flutter 使用 codemagic 构建代码时出现“无法为 iOS 构建”?
为啥在使用 Flutter 模块构建 iOS 原生应用时修复“Frameworks/Flutter.framework: Permission denied”?