This guide is for publishers who want to monetize an iOS app with AdMob and aren't using Firebase. If you plan to include Firebase in your app (or you're considering it), see the AdMob with Firebase version of this guide instead.
Integrating the Google Mobile Ads SDK into an app is the first step toward displaying ads and earning revenue. Once you've integrated the SDK, you can proceed to implement one or more of the supported ad formats.
Prerequisites
- Use Xcode 16.0 or higher
- Target iOS 12.0 or higher
- Recommended: Create an AdMob account and register an app.
Import the Mobile Ads SDK
Use one of the following methods to import the Google Mobile Ads SDK.
Swift Package Manager
To add a package dependency to your project, follow these steps:
In Xcode, install the Google Mobile Ads Swift Package by navigating to File > Add Package Dependencies....
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
Select the version of the Google Mobile Ads Swift Package you want to use. For new projects, we recommend using the Up to Next Major Version.
CocoaPods
Before you continue, review Using CocoaPods for information on creating and using Podfiles.
To use CocoaPods, follow these steps:
Open your project's Podfile and add this line to your app's
target
build configuration:pod 'Google-Mobile-Ads-SDK'
In a terminal, run:
pod install --repo-update
Manual download
Download the Google Mobile Ads SDK and
Embed & Sign
the following frameworks into your Xcode project:GoogleMobileAds.xcframework
UserMessagingPlatform.xcframework
In your project's build settings:
- Add the
/usr/lib/swift
path to Runpath Search Paths. - Add the
-ObjC
linker flag to Other Linker Flags.
- Add the
Update your Info.plist
Update your app's Info.plist
file to add two keys:
A
GADApplicationIdentifier
key with a string value of your AdMob app ID found in the AdMob UI.A
SKAdNetworkItems
key withSKAdNetworkIdentifier
values for Google (cstr6suwn9.skadnetwork
) and select third-party buyers who have provided these values to Google.
Complete snippet
>GADApplicationIdentifier SAMPLE_APP_ID SKAdNetworkItems SKAdNetworkIdentifier cstr6suwn9.skadnetwork SKAdNetworkIdentifier 4fzdc2evr5.skadnetwork SKAdNetworkIdentifier 2fnua5tdw4.skadnetwork SKAdNetworkIdentifier ydx93a7ass.skadnetwork SKAdNetworkIdentifier p78axxw29g.skadnetwork SKAdNetworkIdentifier v72qych5uu.skadnetwork SKAdNetworkIdentifier ludvb6z3bs.skadnetwork SKAdNetworkIdentifier cp8zw746q7.skadnetwork SKAdNetworkIdentifier 3sh42y64q3.skadnetwork SKAdNetworkIdentifier c6k4g5qg8m.skadnetwork SKAdNetworkIdentifier s39g8k73mm.skadnetwork SKAdNetworkIdentifier 3qy4746246.skadnetwork SKAdNetworkIdentifier f38h382jlk.skadnetwork SKAdNetworkIdentifier hs6bdukanm.skadnetwork SKAdNetworkIdentifier mlmmfzh3r3.skadnetwork SKAdNetworkIdentifier v4nxqhlyqp.skadnetwork SKAdNetworkIdentifier wzmmz9fp6w.skadnetwork SKAdNetworkIdentifier su67r6k2v3.skadnetwork SKAdNetworkIdentifier yclnxrl5pm.skadnetwork SKAdNetworkIdentifier t38b2kh725.skadnetwork SKAdNetworkIdentifier 7ug5zh24hu.skadnetwork SKAdNetworkIdentifier gta9lk7p23.skadnetwork SKAdNetworkIdentifier vutu7akeur.skadnetwork SKAdNetworkIdentifier y5ghdn5j9k.skadnetwork SKAdNetworkIdentifier v9wttpbfk9.skadnetwork SKAdNetworkIdentifier n38lu8286q.skadnetwork SKAdNetworkIdentifier 47vhws6wlr.skadnetwork SKAdNetworkIdentifier kbd757ywx3.skadnetwork SKAdNetworkIdentifier 9t245vhmpl.skadnetwork SKAdNetworkIdentifier a2p9lx4jpn.skadnetwork SKAdNetworkIdentifier 22mmun2rn5.skadnetwork SKAdNetworkIdentifier 44jx6755aq.skadnetwork SKAdNetworkIdentifier k674qkevps.skadnetwork SKAdNetworkIdentifier 4468km3ulz.skadnetwork SKAdNetworkIdentifier 2u9pt9hc89.skadnetwork SKAdNetworkIdentifier 8s468mfl3y.skadnetwork SKAdNetworkIdentifier klf5c3l5u5.skadnetwork SKAdNetworkIdentifier ppxm28t8ap.skadnetwork SKAdNetworkIdentifier kbmxgpxpgc.skadnetwork SKAdNetworkIdentifier uw77j35x4d.skadnetwork SKAdNetworkIdentifier 578prtvx9j.skadnetwork SKAdNetworkIdentifier 4dzt52r2t5.skadnetwork SKAdNetworkIdentifier tl55sbb4fm.skadnetwork SKAdNetworkIdentifier c3frkrj4fj.skadnetwork SKAdNetworkIdentifier e5fvkxwrpn.skadnetwork SKAdNetworkIdentifier 8c4e2ghe7u.skadnetwork SKAdNetworkIdentifier 3rd42ekr43.skadnetwork SKAdNetworkIdentifier 97r2b46745.skadnetwork SKAdNetworkIdentifier 3qcr597p9d.skadnetwork
Replace SAMPLE_APP_ID with your AdMob app ID. While testing, use the sample app ID shown in the previous example.
If you haven't created an AdMob account and registered an app yet, now's a great time to do so.
Initialize the Mobile Ads SDK
Before loading ads, call the start()
method on the
GADMobileAds.sharedInstance
,
which initializes the SDK and calls back a completion handler once
initialization is complete (or after a 30-second timeout). Call start()
as
early as possible.
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];
Select an ad format
The Mobile Ads SDK is now imported and initialized, and you're ready to implement an ad. AdMob offers a number of different ad formats, so you can choose the one that best fits your app's user experience.
Banner
Banner ad units display rectangular ads that occupy a portion of an app's layout. They can refresh automatically after a set period of time. This means users view a new ad at regular intervals, even if they stay on the same screen in your app. They're also the simplest ad format to implement.
Interstitial
Interstitial ad units show full-page ads in your app. Place them at natural breaks and transitions in your app's interface, such as after level completion in a gaming app.
Native
Native ads are ads where you can customize the way assets such as headlines and calls to action are presented in your apps. By styling the ad yourself, you can create a natural, unobtrusive ad presentations that can add to a rich user experience.
Rewarded
Rewarded ad units enable users to play games, take surveys, or watch videos to earn in-app rewards, such as coins, extra lives, or points. You can set different rewards for different ad units, and specify the reward values and items the user received.
Rewarded interstitial
Rewarded interstitial is a new type of incentivized ad format that lets you offer rewards, such as coins or extra lives, for ads that appear automatically during natural app transitions.
Unlike rewarded ads, users aren't required to opt in to view a rewarded interstitial.
Instead of the opt-in prompt in rewarded ads, rewarded interstitials require an intro screen that announces the reward and gives users a chance to opt out if they want to do so.
Implement rewarded interstitial ads
App open
App open is an ad format that appears when users open or switch back to your app. The ad overlays the loading screen.