This comprehensive guide will walk you through the process of integrating the Google Mobile Ads SDK into your iOS app for seamless monetization. By following these steps, you'll be able to set up and configure the SDK to display various ad formats, including Banner, Interstitial, Native, Rewarded, and App Open ads.
Prerequisites
Before we dive in, make sure you meet the following requirements:
- Use Xcode 16.0 or higher
- Target iOS 13.0 or higher
- Recommended: Create an AdMob account and register your app
Importing the Google Mobile Ads SDK
To get started with swift app development, you'll need to import the Google Mobile Ads SDK using one of the following methods:
Swift Package Manager
Follow these steps to add the package dependency to your project:
- In Xcode, navigate to File > Add Package Dependencies...
- 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 (we recommend using the Up to Next Major Version)
CocoaPods
If you're already familiar with 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' - Run the command
pod install --repo-updatein a terminal
Manual Download
Alternatively, you can download the Google Mobile Ads SDK and manually embed the necessary frameworks into your Xcode project:
- Download the GoogleMobileAds.xcframework and UserMessagingPlatform.xcframework
- Add the
/usr/lib/swiftpath to Runpath Search Paths and the-ObjClinker flag to Other Linker Flags in your project's build settings
Updating Your Info.plist File
To complete the setup, you'll need to update your app's Info.plist file by adding two keys:
- A
GADApplicationIdentifierkey with a string value of your AdMob app ID found in the AdMob UI - An
SKAdNetworkItemskey withSKAdNetworkIdentifiervalues for Google (cstr6suwn9.skadnetwork) and select third-party buyers who have provided these values to Google
Here's an example of what your updated Info.plist file might look like:
`xml
`
By following these steps, you'll be able to integrate the Google Mobile Ads SDK into your Swift app development project and start monetizing your iOS app with ease.