Set up Google Mobile Ads SDK

  • Integrating the Google Mobile Ads SDK is the first step to displaying ads and earning revenue in your app.

  • You need to use Xcode 16.0 or higher and target iOS 12.0 or higher as prerequisites.

  • The Google Mobile Ads SDK can be imported using Swift Package Manager, CocoaPods, or manual download.

  • You must update your app's Info.plist with your Ad Manager app ID and SKAdNetworkItems for ad functionality and measurement.

  • Before loading ads, initialize the Google Mobile Ads SDK by calling the start() method, ensuring consent and request-specific flags are handled beforehand if needed.

To deliver ads and earn revenue, integrate Google Mobile Ads SDK into your iOS app. To prepare your project, you import and initialize Google Mobile Ads SDK before you request ads.

This guide covers importing and initializing Google Mobile Ads SDK, and selecting an ad format.

Prerequisites

Before you continue, make sure you have the following:

  • Use Xcode 16.0 or higher.
  • Target iOS 13.0 or higher.

Import Google Mobile Ads SDK

To import Google Mobile Ads SDK, complete one of the following sections:

Swift Package Manager

To add a package dependency to your project, follow these steps:

  1. Open Xcode.
  2. Navigate to File > Add Package Dependencies....
  3. Install the Google Mobile Ads SDK Swift Package.

  4. In the prompt that appears, search for the Google Mobile Ads Swift Package GitHub repository:

    https://github.com/googleads/swift-package-manager-google-mobile-ads.git
    
  5. Select the version of the Google Mobile Ads SDK Swift Package you want to use. For new projects, we recommend using Up to Next Major Version.

CocoaPods

To use CocoaPods, follow these steps:

  1. Open your project's Podfile and add this line to your app's target build configuration:

    pod 'Google-Mobile-Ads-SDK'
  2. In a terminal, run:

    pod install --repo-update

Manual download

To manually download Google Mobile Ads SDK, do the following:

  1. Download Google Mobile Ads SDK.
  2. Extract the googlemobileadssdkios.zip package.
  3. In your Xcode project, add the following frameworks:

    • GoogleMobileAds.xcframework
    • UserMessagingPlatform.xcframework
  4. In your target's General settings, navigate to Frameworks, Libraries, and Embedded Content.

  5. Confirm that you've set the GoogleMobileAds.xcframework and UserMessagingPlatform.xcframework to Embed & Sign.

  6. In your project's build settings, do the following:

    • Add the /usr/lib/swift path to Runpath Search Paths.
    • Add the -ObjC linker flag to Other Linker Flags.

Update your Info.plist file

In your app's Info.plist file, add the following keys:

  • A GADApplicationIdentifier key with a string value of your Ad Manager app ID found in the Ad Manager UI and of the form ca-app-pub-################~##########.

  • A SKAdNetworkItems key. This key includes SKAdNetworkIdentifier values for Google cstr6suwn9.skadnetwork and select third-party buyers.

Complete example

<key>GADApplicationIdentifier</key>
<!-- Sample Ad Manager app ID: ca-app-pub-3940256099942544~1458002511 -->
<string>SAMPLE_APP_ID</string>
<key>SKAdNetworkItems</key>
<array>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>cstr6suwn9.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4fzdc2evr5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>2fnua5tdw4.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ydx93a7ass.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>p78axxw29g.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>v72qych5uu.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ludvb6z3bs.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>cp8zw746q7.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3sh42y64q3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>c6k4g5qg8m.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>s39g8k73mm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>wg4vff78zm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3qy4746246.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>f38h382jlk.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>hs6bdukanm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>mlmmfzh3r3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>v4nxqhlyqp.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>wzmmz9fp6w.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>su67r6k2v3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>yclnxrl5pm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>t38b2kh725.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>7ug5zh24hu.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>gta9lk7p23.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>vutu7akeur.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>y5ghdn5j9k.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>v9wttpbfk9.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>n38lu8286q.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>47vhws6wlr.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>kbd757ywx3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>9t245vhmpl.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>a2p9lx4jpn.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>22mmun2rn5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>44jx6755aq.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>k674qkevps.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4468km3ulz.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>2u9pt9hc89.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>8s468mfl3y.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>klf5c3l5u5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ppxm28t8ap.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>kbmxgpxpgc.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>uw77j35x4d.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>578prtvx9j.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4dzt52r2t5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>tl55sbb4fm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>c3frkrj4fj.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>e5fvkxwrpn.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>8c4e2ghe7u.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3rd42ekr43.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>97r2b46745.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3qcr597p9d.skadnetwork</string>
  </dict>
</array>

Replace SAMPLE_APP_ID with your Ad Manager app ID. While testing, use the sample app ID shown in the previous example.

To help your app initialize faster, link your yield groups to specific apps. If a yield group targets iOS, but isn't linked to an app, Google sends the group to all iOS apps in your account. This approach can slow down performance.

Initialize Google Mobile Ads SDK

Before loading ads, initialize Google Mobile Ads SDK by calling the start() method from the GADMobileAds.sharedInstance property. This method calls a completion handler after Google Mobile Ads SDK and mediation adapters finish processing, or after 30 seconds.

The following example initializes Google Mobile Ads SDK:

Swift

// Initialize the Google Mobile Ads SDK.
MobileAds.shared.start()

SwiftUI

// Initialize the Google Mobile Ads SDK.
MobileAds.shared.start()

Objective-C

// Initialize the Google Mobile Ads SDK.
[GADMobileAds.sharedInstance startWithCompletionHandler:nil];

When initializing, Google Mobile Ads SDK might preload ads or initialize third party SDKs when calling the startWithCompletionHandler: method. If you need to obtain consent from users in the European Economic Area (EEA), the United Kingdom (UK), or Switzerland, set request-specific flags. If you need to set request-specific flags, make sure you set the flags before initializing Google Mobile Ads SDK. For details, see Targeting.

Select an ad format

After you import Google Mobile Ads SDK, you can select an ad format to implement.

Ad Manager offers the following ad formats:

Ad format Description Documentation
Banner Shows rectangular ads in a section of your app layout. This ad refreshes automatically at set intervals. Users see these ads periodically when staying on the same screen. Set up banner ads
Interstitial Shows full-page ads in your app. Place this ad at natural breaks and transitions in your app's interface, such as after a level completion in a gaming app. Interstitial ads
Native Lets you customize assets, such as headlines and calls to action, in your apps. When you customize the ad, you create ads that match your app's visual design. Load a native ad
Rewarded Users earn in-app rewards, like coins or points, by playing games, taking surveys, or watching videos. You can set rewards for ad units, and specify the reward values and items your users receive. Rewarded ads
Rewarded interstitial Lets you offer rewards, such as coins or extra lives, for ads that appear during app transitions. Rewarded interstitial ads
App open Appears when users open or go back to your app. The ad overlays the loading screen. App open ads