Hi, Alex here from rebeloper.com and in this video I am going to show you how to
create an Xcode project to receive AdMob banner ads and not just AdMob banner ads
we will create it for interstitial ads and reward-based video ads too.
So without further ado let's get started!
And here we are in our AdMob console and the first thing you need to do is
download the resources I have prepared for you. So go ahead and scroll down and
see the link below. And you will be taken to my site where you can just simply add
access. You just need to add your first name last name and email address and
grant yourself access to the resources. Once you have added access you will be
taken to our special offer and hold on and bare with me I will just scroll down
a little bit and here you will find all that you need to know about The Tribe.
And why you should definitely join The Tribe my flagship product and
subscription you can get it now for a 66% of discount. Go ahead and scroll down
and of course inside The Tribe you will see much much more like these videos and
tutorials. So if you liked it go ahead and subscribe. After that you will
receive an email and you will see that you can go to rebeloper.com/youtube-resources/
or just rebeloper.com/my-loot/ where you can find everything that you
have from Rebeloper. And I will just go there now.
And here you will see a button called YouTube Resources. So go ahead and click
on that. Let's wait for it to load and here you will see that you will be able
to download the AdMob Resources. Now you don't have to download the AdMob
resources you can just follow along the tutorial and type in the code yourself.
But give yourself a favor and do download them it will make your life
much much easier and you will be able to replicate these code snippets you will
see later on you will be able to add these codes in your other projects too
in a matter of seconds. So go ahead let's just download our AdMob Resources and
let's just unpack them. And let's see what we have here. First of all we have
our AdMob tutorial code snippets and here we have a bunch of snippets that we
are going to add to our Xcode and we have a main storyboard file and a pod
file. We will talk about these two later on. For now let's just add our code
snippets to Xcode so we may get those extra second... we may add those codes in a
matter of seconds. So what you need to do is go ahead and go to
Users Rebeloper, your username of course not Rebeloper, Library/Developer/Xcode
and UserData. So again Users (your username)/Library/
/Developer/Xcode/Userdata and inside this Library, this folder... and
one more thing if you can't see your library folder because this library
folder is hidden. Go ahead and in finder the menu click on
Go and tap on your options key and your Library folder should appear when
you click on the alt or option key. So once you are in the usersdata go ahead
and create a new folder if it hasn't already been created called CodeSnippets.
Okay. And all you need to do is copy all of these code snippets and
let's copy this out and paste them here, okay. Next up is to quit Xcode, if you
already have Xcode open and now let's just open up Xcode again. Okay and I have
already open Xcode here and let's see if the code snippets, let me just drag this up...
if the code snippets have appeared. And let's see AdMob and here we have our
code snippets that we will use in our AdMob tutorial, okay. Next up is to create
our Xcode project that we will use for this tutorial. So let's go to file new project
and let it be a Aingle View Application. Let's click on Next and let's give it a Name...
And I like not to add any spaces or funny characters. Let it be just YouTubeAdMob
one word with camelcase capitalization and that's it. And of
course we will use swift as the language. As you can see, yes yes yes the
bundle identifier is com.Rebeloper.YouTubeAdMob as we have set up in the
AdMob dashboard, okay. When we have created, linked our app to the firebase
console. And I will just drop this here on my desktop I will not create a Git
repository because this is just for learning purposes for this tutorial and
I have created it, okay, good stuff here.
Now let's go over back to the downloaded resources and you will see a main.storyboard.
So what is this main.storyboard? This is a starter project
for you as you can see the main.storyboard in the original Xcode project
is just plain old simple storyboard. So I will just go ahead and show it in finder
and now I will just replace it. So I will just copy it and paste the new
storyboard and of course replace it. And let's see our new storyboard. As you can
see I already have two buttons and one banner view. Here is where our AdMob
banner will be showed, good stuff, okay.
And finally we are going to add the necessary pods, AdMob pods that are
required to show an AdMob ad at all. And we are going to do it through Cocoapods
of course because I don't really like to drag and drop libraries into my project
and as our static and cannot be easily updated.
So I advise you too to use Cocoapods. So what you need to do is close the current
Xcode and then navigate to your root folder. And that is a YouTube AdMob here
on my desktop. Now open up terminal, okay. And let me just make this a little
bit bigger with command+, okay. And now we are going to change
directory to our root folder. So type in CD and a space and just simply drag and
drop your folder the root folder of your project into terminal and hit return.
And we are inside our project. Next up is to initialize pod file. Of course you need
to have Cocoapods installed, if you haven't done already so then go ahead
and search for Cocoapods, okay And this is it cocoapods.org and just scroll
down and inside terminal just type in 'sudo gem install cocoapods'. But I also
have a playlist detailing all of the terminal Cocoapods stuff on my youtube
channel. So go ahead and find those too. So let's go back and inside terminal
just type in 'pod init' and hit return. This will create a pod file and let's
take a look at our folder here. And as you can see a pod file has been created.
Now we need to add our specifications for the pods in our pod file so and
we'll just open it with Xcode, okay. Just dragged and dropped it into the icon.
And now under the pots for YouTubeAdMob you need to add two pods. And those are let
me just go back to our pod file that we have downloaded and opened that up too.
Here it is on the right and here we have pod 'Firebase/Core and pod 'Firebase/AdMob'.
Let's just simply copy and paste these two pods here.
And delete this pound sign so the platform should be 9 and above, okay.
Now let's close the example pod file and then save our new pod file. And now that
we have saved the pod file now it's time to install them.
So pod install, okay. And it is downloading dependencies and installing
everything that is needed. Let's wait for it of course this may take a while but
after that you should have installed all of the dependencies
like so. And if you go back to your finder you will see... let me just go
back in our Xcode project near our export project has been created an Xcode
workspace. So from now on as the Terminal says please close any current Xcode
sessions and use the Xcode workspace for this project for now on. So that
is what we are going to do. We are going to open each and every time this Xcode
workspace and this is where we are going to work. So here are our pods and here is
our pod file and our pods that have been downloaded and installed and here is our
project. And as you can see we have our main storyboard and our ViewController.
Okay and of course the app delegate and all of the other launch and launch
screen storyboard and info.plist file. And as a last step to conclude the setup
of our Xcode project we are going to drag and drop that Google info.plist
file, Google services info.plist file. So go ahead and go to your
downloads and select your Google services info.plist file and just drag
and drop it here. Make sure 'Copy items if needed' is checked and create
groups and YouTubeAdMob is selected checked as a target. Now let's click on
finish, okay. And now let's take a look at it and here as you can see we have all
of the metadata that our AdMob SDK or firebase SDK you may call it whatever
you luck needs in order to connect with the Google servers and show you those
nice ads, okay. That is what the Google service info.plist file is for and now
we are ready to write some code. But that will be the topic of another episode.
So that is how you can set up it's really easy to setup your Xcode project to
receive Google AdMob ads. I hope you enjoyed this video. If you did go ahead
and click on the little icon and if you didn't that other button seems to work
okay too or you may share this video with your friends. And if you want to see more
videos like this from me go ahead and click on the subscribe button it really
helps a lot and I will see you in the next one!