Flutter启动macOS应用报错Error running pod install
Flutter macOS端启动pod install报错解决
问题现象
- 仅macOS端启动失败,iOS模拟器、Android模拟器、Chrome网页端运行均无异常
- 设备为M1芯片Mac,终端使用Rosetta转译模式启动
- 此前尝试删除重装iOS目录下Pods依赖,问题未解决
- 报错核心提示:
CocoaPods could not find compatible versions for pod "just_audio",补充说明为该依赖要求更高的最低部署目标版本
VSCode调试控制台报错输出
Launching lib/main.dart on macOS in debug mode... CocoaPods' output: ↳ Preparing Analyzing dependencies Inspecting targets to integrate Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``) Fetching external sources -> Fetching podspec for `FlutterMacOS` from `Flutter/ephemeral` -> Fetching podspec for `audio_session` from `Flutter/ephemeral/.symlinks/plugins/audio_session/macos` -> Fetching podspec for `audioplayers` from `Flutter/ephemeral/.symlinks/plugins/audioplayers/macos` -> Fetching podspec for `device_info_plus_macos` from `Flutter/ephemeral/.symlinks/plugins/device_info_plus_macos/macos` -> Fetching podspec for `flutter_secure_storage_macos` from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos` -> Fetching podspec for `just_audio` from `Flutter/ephemeral/.symlinks/plugins/just_audio/macos` -> Fetching podspec for `package_info_plus_macos` from `Flutter/ephemeral/.symlinks/plugins/package_info_plus_macos/macos` -> Fetching podspec for `path_provider_macos` from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos` -> Fetching podspec for `pdfx` from `Flutter/ephemeral/.symlinks/plugins/pdfx/macos` -> Fetching podspec for `printing` from `Flutter/ephemeral/.symlinks/plugins/printing/macos` -> Fetching podspec for `shared_preferences_macos` from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos` -> Fetching podspec for `sqflite` from `Flutter/ephemeral/.symlinks/plugins/sqflite/macos` -> Fetching podspec for `url_launcher_macos` from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos` -> Fetching podspec for `wakelock_macos` from `Flutter/ephemeral/.symlinks/plugins/wakelock_macos/macos` Resolving dependencies of `Podfile` CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update [!] CocoaPods could not find compatible versions for pod "just_audio": In Podfile: just_audio (from `Flutter/ephemeral/.symlinks/plugins/just_audio/macos`) Specs satisfying the `just_audio (from `Flutter/ephemeral/.symlinks/plugins/just_audio/macos`)` dependency were found, but they required a higher minimum deployment target. /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:317:in `raise_error_unless_state' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:299:in `block in unwind_for_conflict' <internal:kernel>:90:in `tap' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:297:in `unwind_for_conflict' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:682:in `attempt_to_activate' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:254:in `process_topmost_state' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/resolver.rb:94:in `resolve' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1078:in `block in resolve_dependencies' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:1076:in `resolve_dependencies' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer/analyzer.rb:124:in `analyze' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:416:in `analyze' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:241:in `block in resolve_dependencies' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/user_interface.rb:64:in `section' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:240:in `resolve_dependencies' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/installer.rb:161:in `install!' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:52:in `run' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/bin/pod:25:in `load' /opt/homebrew/Cellar/cocoapods/1.11.3/libexec/bin/pod:25:in `<main>' Exception: Error running pod install Exited
flutter doctor -v 执行结果
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-arm (Rosetta), locale en-US) • Flutter version 3.0.2 at /Users/jackestes/Flutter/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision cd41fdd495 (7 days ago), 2022-06-08 09:52:13 -0700 • Engine revision f15f824b57 • Dart version 2.17.3 • DevTools version 2.12.2 [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) • Android SDK at /Users/jackestes/Library/Android/sdk • Platform android-32, build-tools 32.1.0-rc1 • Java binary at: /opt/homebrew/Cellar/openjdk/18.0.1.1/libexec/openjdk.jdk/Contents/Home/bi n/java • Java version OpenJDK Runtime Environment Homebrew (build 18.0.1.1+0) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.4.1) • Xcode at /Applications/Coding/Xcode.app/Contents/Developer • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.2) • Android Studio at /Applications/Coding/Android Studio.app/Contents • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) [✓] IntelliJ IDEA Ultimate Edition (version 2022.1.1) • IntelliJ at /Applications/Coding/IntelliJ IDEA.app [✓] VS Code (version 1.68.1) • VS Code at /Applications/Coding/Visual Studio Code.app/Contents • Flutter extension version 3.42.0 [✓] Connected device (2 available) • macOS (desktop) • macos • darwin-arm64 • macOS 12.4 21F79 darwin-arm (Rosetta) • Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.115 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found!
问题原因
报错出在macOS端的CocoaPods依赖解析环节,和iOS端依赖完全无关,之前重装iOS目录下的Pods属于操作错了目录。核心问题是项目macOS端配置的最低系统部署版本低于just_audio插件macOS端要求的最低版本,导致依赖无法匹配。
解决步骤
- 打开项目路径下的
macos/Podfile文件,找到文件开头的系统版本配置行,默认配置一般为platform :osx, '10.11',将版本号修改为10.13及以上(如果后续其他插件报同类版本不兼容错误,可适当调高到10.15) - 终端进入项目的macOS目录,执行依赖清理和重装命令:
cd macos rm -rf Pods Podfile.lock pod repo update pod install
- 回到项目根目录,执行Flutter清理后重新运行即可:
cd .. flutter clean flutter pub get flutter run -d macos
注意:M1芯片设备如果执行pod命令时出现架构兼容报错,可以在pod命令前加arch -x86_64前缀执行,适配Rosetta转译环境。
内容的提问来源于stack exchange,提问作者Jack Estes
相关产品推荐
相关产品推荐

