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

M2芯片Mac上Flutter iOS启动失败:找不到google_sign_in_ios的podspec

Flutter iOS端启动失败问题解决

问题概况

Android端运行正常,iOS模拟器启动失败,报错核心为No podspec found for google_sign_in_ios in .symlinks/plugins/google_sign_in_ios/darwin,同时Podfile未指定iOS平台。M2芯片MacBook Pro上操作无效,但相同代码在Intel Mac可正常运行,曾尝试添加MacOS构建后回滚,已执行卸载重装CocoaPods、清理缓存、flutter clean、pod install、pod repo update等操作。

报错信息

Launching lib/main.dart on iPhone 14 Plus (6.7-inch) in debug mode...
Running pod install...
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

    Finding Podfile changes
      ..
      - google_mobile_ads
      - google_sign_in_ios
      ...

    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `app_tracking_transparency` from `.symlinks/plugins/app_tracking_transparency/ios`
    -> Fetching podspec for `file_picker` from `.symlinks/plugins/file_picker/ios`
    -> Fetching podspec for `flutter_native_splash` from `.symlinks/plugins/flutter_native_splash/ios`
    -> Fetching podspec for `google_mobile_ads` from `.symlinks/plugins/google_mobile_ads/ios`
    -> Fetching podspec for `google_sign_in_ios` from `.symlinks/plugins/google_sign_in_ios/darwin`
    [!] No podspec found for `google_sign_in_ios` in `.symlinks/plugins/google_sign_in_ios/darwin`

    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/external_sources/path_source.rb:14:in `block in fetch'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/external_sources/path_source.rb:11:in `fetch'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:997:in `fetch_external_source'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:976:in `block (2 levels) in fetch_external_sources'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:975:in `each'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:975:in `block in fetch_external_sources'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:974:in `fetch_external_sources'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:118:in `analyze'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:422:in `analyze'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:162:in `install!'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/bin/pod:25:in `load'
    /opt/homebrew/Cellar/cocoapods/1.15.2/libexec/bin/pod:25:in `<main>'

Error output from CocoaPods:
↳

    [!] Automatically assigning platform `iOS` with version `15.2` 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 14 Plus (6.7-inch).

相关配置(pubspec.yaml)

# versions available, run `flutter pub outdated`.
version: 1.0.0+1

environment:
  sdk: '>=3.2.0 <4.0.0'

dependencies:
  flutter:
    sdk: flutter

  #...
  # other dependencies.
  #...
  googleapis: ^11.4.0
  google_sign_in: ^6.2.1
  extension_google_sign_in_as_googleapis_auth: ^2.0.11

解决方案

1. 修复google_sign_in_ios路径错误

该问题源于Flutter生成的symlink指向了错误的目录(darwin而非ios),是添加MacOS构建后回滚留下的残留问题,执行以下步骤:

  • 执行flutter clean清理项目缓存
  • 进入项目根目录下的ios文件夹,删除Podfile.lock、Pods文件夹和Runner.xcworkspace文件
  • 回到项目根目录,执行flutter pub get重新生成正确的插件symlink

2. 指定Podfile iOS平台版本

打开ios/Podfile,在文件开头添加平台指定代码(版本可根据项目需求调整):

platform :ios, '15.0'

3. 适配M芯片架构(可选)

针对M系列芯片Mac,在ios/Podfile的post_install区块添加架构兼容配置:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    # 兼容arm64和x86_64架构
    target.build_configurations.each do |config|
      config.build_settings['ARCHS[sdk=iphonesimulator*]'] = 'arm64 x86_64'
    end
  end
end

4. 重新安装Pods

进入ios文件夹,执行:

pod install --repo-update

完成以上步骤后,重新启动iOS模拟器即可正常运行应用。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 04:45:54