Flutter项目中pod install命令执行失败(trunk仓库更新失败)
Flutter项目
pod install报错解决指南 问题现象
在Flutter项目的ios目录执行pod install命令时出现两类错误:CDN trunk仓库更新失败(SSL连接错误),以及Xcode项目配置存在未知UUID,多次重装CocoaPods无法解决。
完整报错信息
Analyzing dependencies [!] CDN: trunk Repo update failed - 9 error(s): CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/4/2/c/FlutterMacOS/1.12.1303/FlutterMacOS.podspec.json Response: SSL connect error CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/4/2/c/FlutterMacOS/1.17.0/FlutterMacOS.podspec.json Response: SSL connect error CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/4/2/c/FlutterMacOS/1.22.4/FlutterMacOS.podspec.json Response: SSL connect error CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/4/2/c/FlutterMacOS/1.9.102/FlutterMacOS.podspec.json Response: SSL connect error CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/4/2/c/FlutterMacOS/2.0.0/FlutterMacOS.podspec.json Response: SSL connect error CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/4/2/c/FlutterMacOS/2.10.2/FlutterMacOS.podspec.json Response: SSL connect error CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/4/2/c/FlutterMacOS/2.2.2/FlutterMacOS.podspec.json Response: SSL connect error CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/4/2/c/FlutterMacOS/2.5/FlutterMacOS.podspec.json Response: SSL connect error CDN: trunk URL couldn't be downloaded: https://cdn.jsdelivr.net/cocoa/Specs/4/2/c/FlutterMacOS/3.0.0/FlutterMacOS.podspec.json Response: SSL connect error [!] `<XCBuildConfiguration name=`Debug` UUID=`331C8088294A63A400263BE5`>` attempted to initialize an object with an unknown UUID. `AE0B7B92F70575B8D7E0D07E` for attribute: `base_configuration_reference`. This can be the result of a merge and the unknown UUID is being discarded. [!] `<XCBuildConfiguration name=`Release` UUID=`331C8089294A63A400263BE5`>` attempted to initialize an object with an unknown UUID. `89B67EB44CE7B6631473024E` for attribute: `base_configuration_reference`. This can be the result of a merge and the unknown UUID is being discarded. [!] `<XCBuildConfiguration name=`Profile` UUID=`331C808A294A63A400263BE5`>` attempted to initialize an object with an unknown UUID. `640959BDD8F10B91D80A66BE` for attribute: `base_configuration_reference`. This can be the result of a merge and the unknown UUID is being discarded. [!] `<PBXNativeTarget name=`RunnerTests` UUID=`331C8080294A63A400263BE5`>` attempted to initialize an object with an unknown UUID. `331C807E294A63A400263BE5` for attribute: `build_phases`. This can be the result of a merge and the unknown UUID is being discarded.
环境信息
- Ruby版本:
ruby 2.6.8p205 (2021-07-07 revision 67951) [arm64-darwin22] - CocoaPods版本:
1.12.1 - Flutter Doctor摘要:
Doctor summary (to see all details, run flutter doctor -v): [!] Flutter (Channel stable, 3.10.6, on macOS 13.4 22F66 darwin-arm64, locale en-EG) ! Warning: `flutter` on your path resolves to /Users/fadyfouad/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/fadyfouad/Flutter. Consider adding /Users/fadyfouad/Flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/fadyfouad/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/fadyfouad/Flutter. Consider adding /Users/fadyfouad/Flutter/bin to the front of your path. [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) [✓] Xcode - develop for iOS and macOS (Xcode 14.3) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.2) [✓] IntelliJ IDEA Ultimate Edition (version 2022.3.1) [✓] VS Code (version 1.79.2) [✓] Connected device (3 available) [✓] Network resources
解决步骤
1. 修复Flutter路径警告
修改终端环境变量,将当前Flutter SDK路径放到PATH最前面:
- 打开终端配置文件(比如
~/.zshrc或~/.bash_profile) - 添加一行:
export PATH="/Users/fadyfouad/Flutter/bin:$PATH" - 执行
source ~/.zshrc(对应你的配置文件)使修改生效
2. 解决CDN SSL连接错误
方案一:切换到国内CocoaPods镜像
# 移除默认trunk源 pod repo remove trunk # 添加阿里云镜像源 pod repo add trunk https://mirrors.aliyun.com/cocoapods/specs/
或者直接修改项目根目录的Podfile,在顶部替换源:
# 注释掉原来的源,添加国内源 source 'https://mirrors.aliyun.com/cocoapods/specs/' # source 'https://cdn.jsdelivr.net/cocoa/Specs/'
方案二:禁用仓库更新
执行pod install时跳过仓库更新:
pod install --no-repo-update
3. 解决Xcode项目UUID错误
- 删除ios目录下的
Pods文件夹、Podfile.lock、Runner.xcworkspace - 执行
flutter clean清理Flutter缓存 - 用Xcode打开
Runner.xcodeproj:- 选中
Runnertarget,进入Build Settings,搜索Base Configuration,确认路径指向正确的.xcconfig文件 - 若RunnerTests报错,可暂时删除该target(如果不需要测试功能),之后重新执行
flutter create .(在项目根目录)恢复测试target
- 选中
- 重新进入ios目录执行
pod install
内容的提问来源于stack exchange,提问作者FadyFouad
相关产品推荐
相关产品推荐

