Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: Wrong instruction in installing Google Mobile Ads SDK?

Tags:

ios

admob

I'm following this tutorial to put Google Ad on my page: https://firebase.google.com/docs/admob/ios/quick-start

At the step:

GADMobileAds.configureWithApplicationID("ca-app-pub-8123415297019784~8909888406");

And the error occurred:

AppDelegate.swift:58:9: Type 'GADMobileAds' has no member 'configureWithApplicationID'

And after the checking, i see there is no member configureWithApplicationID.

What's wrong with this instruction? And why i have to install Firebase/Core in this version?

Here are methods in GADMobileAds, there is no configureWithApplicationID like Objective C version. How stupid is that http://i.imgur.com/Od0vkPg.png

like image 406
TomSawyer Avatar asked Jul 15 '16 17:07

TomSawyer


2 Answers

Remove the cocoapods line from the instruction and replace with this line:

pod 'Google-Mobile-Ads-SDK'

It will install the google sdk version 7.9.0 and you'll see the configureWithApplicationID method. This is the error from Google for Swift.

like image 89
TomSawyer Avatar answered Oct 04 '22 22:10

TomSawyer


Xcode 7.3, iOS9.3.3

Followed the instructions above, but wanted to expand, in hopes of saving someone time. If you had 'Google-Mobile-Ads-SDK' pod already installed, then check the version to make sure it is 7.9.0+. Otherwise, you will keep installing the old version over and over.

To update the version, follow the instruction taken from Cocoapods website https://cocoapods.org/pods/Google-Mobile-Ads-SDK click "Installation Guide" (bottom right):

enter image description here

The '~> 7.9' bit will force an update.

What I had that did not work:

enter image description here

What it needs to be:

enter image description here

Again, note the version is 7.9.1

The Podfile looks like this:

# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'

target 'AppName' do
  # Uncomment this line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for AppName

  pod 'Firebase'
  pod 'Google-Mobile-Ads-SDK', '~> 7.9'

  target 'AppNameTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

Now you will be able to configure GADMobileAds with the Google prescribed method:

[GADMobileAds configureWithApplicationID:@""];

Or the Swift equivalent:

GADMobileAds.configureWithApplicationID("");

Hope this helps! Cheers.

like image 24
serge-k Avatar answered Oct 04 '22 22:10

serge-k