Hey everyone, welcome Today, I’m excited to show you how to implement AdMob banner ads in your iOS app super easily. This time, my blog is a little different because I discovered a quick and straightforward method to get those banner ads up and running in no time. So, let’s dive right in!
Implementing AdMob Banner Ads in Your iOS App: A Step-by-Step Guide 2024
Getting Started
first, let’s make sure we have everything we need. Open your Xcode project and navigate to your project’s directory in the terminal.
Table of Contents
Step 1: Initialize CocoaPods
To manage dependencies, we’ll use CocoaPods. Initialize CocoaPods in your project by typing:
pod init
This command creates a Podfile
in your project directory.
Step 2: Edit the Podfile
Open the Podfile
using your favorite text editor and add the Google Mobile Ads SDK under your target. You Podfile
should look something like this:
target 'YourAppName' do
pod 'Google-Mobile-Ads-SDK'
end
Save the file and return it to your terminal. Now, install the pod by typing:
pod install
This command will install the Google Mobile Ads SDK into your project.
Setting Up AdMob
Add Your App to AdMob
- Go to the AdMob website and log in to your account.
- Click on the “Apps” tab on the left sidebar.
- Click on the “Add app” button.
Here, you need to specify whether your app is already in the app store. In my case, I am selecting “No” and clicking “Continue.”
- Select the platform (iOS).
- Enter your app’s name and click “Add.”
Step 4: Create an Ad Unit
- Once your app is added to AdMob, we need to create an ad unit.
- Choose “Banner” as the ad format.
- Enter a name for your ad unit, something like “iOS_Banner_Ad” for easy reference, and click “Create an ad unit.”
- After creating the ad unit, you’ll see your ad unit ID. Copy this ID—we’ll need it for integrating the ad into our iOS app.
Integrating the AdMob Banner Ad in Your iOS App
Step 5: Configure Your App for AdMob
- Open your Xcode project.
- Create bannerAd.swift(copy the below code)
Configure info.plist
Now, there’s one more crucial step. We need to configure our Info.plist
file to ensure our app can properly request ads. Open your Info.plist
file from the Google Admob
And that’s it! You’ve successfully added your app to Google Mobile Ads, created a banner ad for iOS, and configured your Info.plist
to support ad requests.. As always, if you have any questions or run into any issues, leave a comment below and I’ll be happy to help.
Thanks for watching, and I’ll see you in the next blog!
Leave a Reply