Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

292
Views
Cannot find type 'GADInterstitial' in scope?

I just upgraded Google Mobile Ads SDK to version 8.0, but I am getting this error:

Cannot find type 'GADInterstitial' in scope

I also added this code to AppDelegate:

GADMobileAds.sharedInstance().start(completionHandler: nil)

Google Mobile Ads SDK worked perfectly until I upgraded to version 8.0

Note: I also use Firebase Framework in my app.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Google have updated the SDK without telling anyone. Take a look at the new guide on Admob for adding an interstitial. Essentially GADInterstitial has changed to GADInterterstitialAd and you have to use a different Delegate too.

Thanks for that Google.

over 4 years ago · Santiago Trujillo Report

0

Here this is the code of Admob Interstitial only copy and paste I just upgraded Google Mobile Ads SDK to version 8.0

import GoogleMobileAds

class ViewController: UIViewController,GADFullScreenContentDelegate{
    
private var interstitial: GADInterstitialAd?
    
override func viewDidLoad() {
    super.viewDidLoad()
    
    let request = GADRequest()
        GADInterstitialAd.load(withAdUnitID:"ca-app-pub-3940256099942544/4411468910",request: request,
        completionHandler: { [self] ad, error in
          if let error = error {
             return
             }
             interstitial = ad
             interstitial?.fullScreenContentDelegate = self
            }
        )
}

 func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
   print("Ad did fail to present full screen content.")
 }

 func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
   print("Ad did present full screen content.")
 }

 func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
   print("Ad did dismiss full screen content.")
 }   

@IBAction func AddAction(_ sender: UIButton) {        
    if interstitial != nil {
        interstitial.present(fromRootViewController: self)
      } else {
        print("Ad wasn't ready")
      }
}         

}

over 4 years ago · Santiago Trujillo Report

0

Google Mobile Ads SDK 8.0 has a dramatic change of its API interfaces. Please refer to Google's official document for Interstitial. To make it complete, here is the reference to the legacy API prior to 8.0.

The main changes are the delegate and the Ad class:

old new
GADInterstitialDelegate GADFullScreenContentDelegate
GADInterstitial GADInterstitialAd

And instead of initializing the Ad in the legacy way:

interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910")
let request = GADRequest()
interstitial.load(request)

it's now initialized in the following way

let request = GADRequest()
GADInterstitialAd.load(withAdUnitID:"ca-app-pub-3940256099942544/4411468910",
                            request: request,
                  completionHandler: { [self] ad, error in
                    if let error = error {
                      print("Failed to load interstitial ad with error: \(error.localizedDescription)")
                      return
                    }
                    interstitial = ad
                    interstitial?.delegate = self
                  }

And the new GADFullScreenContentDelegate methods:

/// Tells the delegate that the ad failed to present full screen content.
func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
  print("Ad did fail to present full screen content.")
}

/// Tells the delegate that the ad presented full screen content.
func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did present full screen content.")
}

/// Tells the delegate that the ad dismissed full screen content.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
  print("Ad did dismiss full screen content.")
}

Note there is no longer the interstitialDidReceiveAd method. Instead you either start to present the Ad in the GADInterstitialAd.load() completion call back, or at a later stage to present the Ad if it is initialized:

if interstitial != nil {
  interstitial.present(fromRootViewController: self)
} else {
  print("Ad wasn't ready")
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!