I am a beginner.

I want to display an interstitial ad before the label changes when I press the button in the diagram in Xcode.

install cocoapod
Prepared the podfile in the folder with the Pod init command.

podPod was installed in the Xcode project with pod install.

While reading the help of AdMob site (https://developers.google.com/admob/ios/quick-start),
I have imported the Mobile Ads SDK.


Updated Info.plist.

Mobile ads have been initialized.
(Import GoogleMobileAds into the program of AppDelegate.swift
, GADMobileAds.sharedInstance().start(added completionHandler: nil)

After that, I ran the program as follows, but I got an error.

How can I implement AdMob?

  • Answer # 1

    I think this is because "}" is inserted before the if statement.

    label.text = "Wan Wan"}<- This part
    if interstitial.isReady {
      // omitted

    The expected declaration error appears when you declare something other than a property or method in a class.
    In that case, it's good to check whether there are too many brackets {}.