iOS模拟器运行Flutter应用失败:libphonenumber_plugin Pod兼容问题
解决Flutter项目iOS端Pod install失败问题
在iOS模拟器运行名为coincrux的Flutter项目时,Pod install执行失败,报错信息如下:
[!] CocoaPods could not find compatible versions for pod "libphonenumber_plugin": In Podfile: libphonenumber_plugin (from `.symlinks/plugins/libphonenumber_plugin/ios`) Specs satisfying the `libphonenumber_plugin (from `.symlinks/plugins/libphonenumber_plugin/ios`)` dependency were found, but they required a higher minimum deployment target. Failed to run Pod install.
项目配置文件
pubspec.yaml
name: coincrux description: A Flutter project fro Astute Technologies publish_to: 'none' version: 1.0.0+1 environment: sdk: '>=2.19.4 <3.0.0' dependencies: cached_network_image: ^3.2.3 candlesticks: ^2.1.0 carousel_slider: ^4.2.1 cloud_firestore: ^4.13.1 cupertino_icons: ^1.0.2 curved_navigation_bar: ^1.0.3 firebase_auth: ^4.6.3 firebase_core: ^2.20.0 firebase_messaging: ^14.7.10 firebase_storage: ^11.5.1 flutter: sdk: flutter flutter_card_swiper: ^6.0.0 flutter_launcher_icons: ^0.13.1 get: ^4.6.5 google_sign_in: ^6.1.4 http: ^1.1.2 image_picker: ^1.0.0 intl_phone_number_input: ^0.7.3+1 photo_view: ^0.14.0 pin_code_fields: ^8.0.1 provider: ^6.0.5 share_plus: ^7.0.1 shared_preferences: ^2.2.1 timeago: ^3.5.0 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 flutter_icons: android: "launcher_icon" ios: true image_path: "assets/images/splashicon.png" flutter: uses-material-design: true assets: - assets/images/ fonts: - family: RobotoFlex fonts: - asset: assets/fonts/RobotoFlex.ttf
Podfile
# Uncomment this line to define a global platform for your project platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 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__)) #target 'RunnerTests' do # inherit! :search_paths #end end post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) end end
解决步骤
报错核心原因:libphonenumber_plugin依赖要求更高的iOS最低部署版本,当前Podfile设置的iOS 11.0不满足要求,按以下步骤修复:
升级iOS部署目标
打开ios/Podfile,将platform :ios, '11.0'修改为platform :ios, '12.0'(或更高版本,比如13.0,可根据依赖兼容情况调整)清理缓存并重新安装依赖
依次执行以下命令:flutter clean cd ios pod deintegrate pod install cd .. flutter pub get(可选)降级依赖版本
若不想升级iOS部署目标,可尝试降低intl_phone_number_input的版本(libphonenumber_plugin是它的间接依赖),但此方法可能引发其他兼容问题,优先推荐升级iOS部署目标。
内容的提问来源于stack exchange,提问作者Phani
相关产品推荐
相关产品推荐

