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

Flutter iOS模拟器运行报错:Pods-Runner存在libgsdk.a库命名冲突

解决Flutter iOS项目中libgsdk.a库冲突问题

错误信息

[!] The 'Pods-Runner' target has libraries with conflicting names: libgsdk.a.

    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/target_validator.rb:67:in `verify_no_duplicate_names'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/target_validator.rb:58:in `block (2 levels) in
    verify_no_duplicate_framework_and_library_names'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/target_validator.rb:48:in `each_key'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/target_validator.rb:48:in `block in
    verify_no_duplicate_framework_and_library_names'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/target_validator.rb:47:in `each'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/target_validator.rb:47:in
    `verify_no_duplicate_framework_and_library_names'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/target_validator.rb:37:in `validate!'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:666:in `validate_targets'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:164:in `install!'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/command/install.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/lib/cocoapods/command.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/gems/cocoapods-1.14.3/bin/pod:55:in `<top (required)>'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/bin/pod:25:in `load'
    /opt/homebrew/Cellar/cocoapods/1.14.3/libexec/bin/pod:25:in `<main>'

解决步骤

1. 定位重复依赖的来源

libgsdk.a一般是第三方SDK的静态库,冲突源于多个Flutter插件同时引入了该库。执行以下命令找出重复引入的插件:

cd ios
pod deintegrate
pod install --verbose | grep libgsdk.a

从输出中提取包含该库的插件名称。

2. 排除重复的库

在ios/Podfile中,针对重复引入的插件添加过滤规则:

# 示例:假设flutter_xxx_plugin重复引入了libgsdk.a
pod 'flutter_xxx_plugin', :path => '../plugins/flutter_xxx_plugin' do
  exclude_files => '**/libgsdk.a'
end

若不确定具体插件,可在Podfile末尾添加全局处理规则:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.frameworks_build_phase.files.each do |file|
      if file.file_ref.name == 'libgsdk.a'
        file.remove_from_project
      end
    end
  end
end

3. 清理并重新安装依赖

执行命令彻底清理后重新构建依赖:

cd ios
pod deintegrate
rm Podfile.lock
rm -rf ../.symlinks
flutter clean
flutter pub get
pod install

4. 手动检查Xcode配置(可选)

若上述步骤无效,打开ios/Runner.xcworkspace:

  • 进入Runner target的Build Phases -> Link Binary With Libraries
  • 删除多余的libgsdk.a条目,仅保留一个

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 05:35:29