You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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:
    • 选中Runner target,进入Build Settings,搜索Base Configuration,确认路径指向正确的.xcconfig文件
    • 若RunnerTests报错,可暂时删除该target(如果不需要测试功能),之后重新执行flutter create .(在项目根目录)恢复测试target
  • 重新进入ios目录执行pod install

内容的提问来源于stack exchange,提问作者FadyFouad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 22:47:18