Tuesday, March 31, 2015

How to integrate Admob into Unity 5 iOS build

I am using MacOS Mavericks, Unity 5 Personal Edition, and XCode 6.1
For integrating Admob into Unity Android, see this post.

Download Unity plugin from here:


At time of writing the latest  is Google Mobile Ads Unity Plugin v2.2

Download it and import to unity after creating a Plugins folder in Assets.

Insert the necessary code to call your Admob Banner and Interstitial ads. For me I wrote a custom script called AdsController.cs:

using UnityEngine;
using System.Collections;
using GoogleMobileAds.Api;
using System;  // For EventArgs

public class AdsController : MonoBehaviour {
    InterstitialAd interstitial;
    BannerView bannerView;

    void Start () {

//------ Banner Ad -------
        // Create a 320x50 banner at the top of the screen.
        // Put your Admob banner ad id here
        bannerView = new BannerView(
        // Create ad request
        AdRequest request = new AdRequest.Builder().Build();
        // Load the banner with the request.

//---- Interstitial Ad -----
        // Initialize an InterstitialAd.
        // Put your admob interstitial ad id here:
        interstitial = new InterstitialAd("

        //Add callback for when ad is loaded
        interstitial.AdLoaded += HandleAdLoaded;

        // Create an ad request.
        AdRequest requestInterstitial = new AdRequest.Builder().Build();
        // Load the interstitial with the request.

    public void HandleAdLoaded(object senderEventArgs args) {
        interstitial.Show ();

    void OnDestroy(){
        if (interstitial!=null) {
            interstitial.AdLoaded -= HandleAdLoaded;
            interstitial.Destroy ();
            bannerView.Destroy ();


Put the script above in Game Over scene, or, Level Cleared scene. So that when the scene loads, the banner and interstitial ads get called and shown at the same time.

Next, build the Unity iOS XCode project with the player setttings shown here (on right side of screen):

Download the iOS Google Mobile Ads SDK v7 from:

Unzip the file and you will get:


Open the exported Unity project in Xcode6 and add the GoogleMobileAds.framework to your project:

Enable modules in Xcode Build Settings:

Plug your iPad/iPhone in and run.

1 comment:

  1. all in on plugin ,https://github.com/unity-plugins/Unity-Admob