【问题标题】:'Cannot find type 'GADInterstitialAd' in scope' error“在范围内找不到类型‘GADInterstitialAd’”错误
【发布时间】:2021-12-06 03:57:47
【问题描述】:

您好,我在 XCode 上存档我的应​​用程序时收到此错误。该应用程序在模拟器和物理设备上正常运行,但是当我尝试存档时出现此错误:

在范围内找不到类型“GADInterstitialAd”

这是 pod 文件:

pod 'Google-Mobile-Ads-SDK','~>8.0'

我也像这样导入 Google 广告:

导入 GoogleMobileAds

这是插页式实现:

GADInterstitialAd.load(withAdUnitID: NSLocalizedString("interstitial_id", comment: ""), request: request, completionHandler: {[weak self] (ad, error) in
        if error != nil {
            return
        }
        self!.interstitial = ad
        self!.interstitial.fullScreenContentDelegate = self
    })

【问题讨论】:

  • 为什么 self 被强制解包?

标签: ios swift xcode admob ads


【解决方案1】:

您可能正在使用旧版 API 进行插页式广告。 Google 有时会更改 API 而不会正确告知所有人。

尝试在您使用 GAMInterstitialAd.load 而不是 GADInterstitialAd.load 的情况下实施新的插页式广告 API。

这里是新 api 的文档:Google Intersticial API link

【讨论】:

  • 我更新了实现但仍然是同样的问题:Cannot find type 'GAMInterstitialAd' in scope
【解决方案2】:

我通过手动将 Pod 移至回收站解决了这个问题,因为 pod deintegrate 不起作用,我从头开始重新安装了所有 Pod。然后我手动将 Google Ads SDK 框架添加到 Link Binary With Libraries

【讨论】:

    猜你喜欢
    • 2022-11-27
    • 2021-09-24
    • 2021-09-21
    • 2021-08-01
    • 2022-01-16
    • 2021-08-03
    • 2021-11-29
    • 2021-09-23
    • 1970-01-01
    相关资源
    最近更新 更多