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

Swift项目通过CocoaPods集成google_mobile_ads SDK后报错

解决Google Mobile Ads SDK v11.6.0集成后的链接错误

在Swift项目中集成google_mobile_ads SDK v11.6.0后,运行时出现如下链接错误,移除SDK后项目可正常运行:

ld: warning: Could not find or use auto-linked library 'swiftXPC': library 'swiftXPC' not found
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
ld: warning: Could not find or use auto-linked framework 'MarketplaceKit': framework 'MarketplaceKit' not found
ld: Undefined symbols:
  enum case for MarketplaceKit.AppDistributor.testFlight(MarketplaceKit.AppDistributor.Type) -> MarketplaceKit.AppDistributor, referenced from:
      l007 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
      l008 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
  enum case for MarketplaceKit.AppDistributor.marketplace(MarketplaceKit.AppDistributor.Type) -> (Swift.String) -> MarketplaceKit.AppDistributor, referenced from:
      l007 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
      l008 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
  enum case for MarketplaceKit.AppDistributor.other(MarketplaceKit.AppDistributor.Type) -> MarketplaceKit.AppDistributor, referenced from:
      l007 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
      l008 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
  static MarketplaceKit.AppDistributor.current.getter : MarketplaceKit.AppDistributor, referenced from:
      function signature specialization <Arg[0] = Dead> of static GoogleMobileAds.GADMarketplaceKitSignals.appDistributor() async -> Swift.String in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
  async function pointer to static MarketplaceKit.AppDistributor.current.getter : MarketplaceKit.AppDistributor, referenced from:
      function signature specialization <Arg[0] = Dead> of static GoogleMobileAds.GADMarketplaceKitSignals.appDistributor() async -> Swift.String in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
  enum case for MarketplaceKit.AppDistributor.appStore(MarketplaceKit.AppDistributor.Type) -> MarketplaceKit.AppDistributor, referenced from:
      l007 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
      l008 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
  type metadata accessor for MarketplaceKit.AppDistributor, referenced from:
      l007 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
      l008 in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
  nominal type descriptor for MarketplaceKit.AppDistributor, referenced from:
      _symbolic _____Sg 14MarketplaceKit14AppDistributorO in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
  __swift_FORCE_LOAD_$_swiftXPC, referenced from:
      __swift_FORCE_LOAD_$_swiftXPC_$_GoogleMobileAds in GoogleMobileAds[arm64][423](GADMarketplaceKitSignals.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决步骤:

  • 检查Xcode版本兼容性:Google Mobile Ads SDK v11.6.0要求Xcode 15.0及以上版本,确保你的Xcode版本符合要求,版本过低则升级Xcode。
  • 配置链接器忽略私有依赖:
    1. 打开项目Target的Build Settings,找到Other Linker Flags
    2. 添加以下参数:
      • -weak_framework MarketplaceKit
      • -weak-lswiftXPC
        该配置会让链接器忽略这些私有框架/库的缺失,避免报错。
  • 手动添加公开框架:在项目Target的Build Phases -> Link Binary With Libraries中,点击+号,搜索并添加CoreAudioTypes.framework。
  • 清理并重新构建:
    1. 使用Cmd+Shift+K清理项目
    2. 前往Window -> Organizer,选中当前项目,点击Delete Derived Data删除缓存
    3. 重新执行Cmd+B构建项目
  • 重新同步SDK依赖:如果使用CocoaPods集成,执行以下命令重新安装依赖:
    pod deintegrate
    pod install
    
    若手动集成SDK,检查下载的SDK包是否完整,重新替换完整的SDK文件。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 00:45:21