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:

  1. In Xcode, navigate to File > Add Package Dependencies...
  2. Search for the Google Mobile Ads Swift Package GitHub repository: https://github.com/googleads/swift-package-manager-google-mobile-ads.git
  3. 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:

  1. Open your project's Podfile and add this line to your app's target build configuration: pod 'Google-Mobile-Ads-SDK'
  2. Run the command pod install --repo-update in a terminal

Manual Download

Alternatively, you can download the Google Mobile Ads SDK and manually embed the necessary frameworks into your Xcode project:

  1. Download the GoogleMobileAds.xcframework and UserMessagingPlatform.xcframework
  2. Add the /usr/lib/swift path to Runpath Search Paths and the -ObjC linker 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:

  1. A GADApplicationIdentifier key with a string value of your AdMob app ID found in the AdMob UI
  2. An SKAdNetworkItems key with SKAdNetworkIdentifier values 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

GADApplicationIdentifier

SAMPLE_APP_ID

SKAdNetworkItems

SKAdNetworkIdentifier

cstr6suwn9.skadnetwork

`

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.