11

I have a problem using the Google AdMob Framework with Swift 2.0. I'm using AdMob for the first time so I do not know if the problem is with AdMob or Swift 2.0.

I have included the AdMob Framework and import it like that in my ViewController:

import GoogleMobileAds

The error I am getting is:

No such Module GoogleMobileAds

A bridging header is also not working:

#import <GoogleMobileAds/GoogleMobileAds.h>

The Error:

GoogleMobileAds/GoogleMobileAds.h file not found

How should I include AdMob? I have tested AdMob 6.12.2 and included it via the bridging header and it works.

The previous posts from other users didn't help me - there were no solutions for this problem.

1

7 Answers 7

11

Right click your project -> Show in Finder -> Create New Folder and copy GoogleMobileAds.framework after open project.

Select project-> Targets -> Build Phases -> Link Binary With Libraries -> click "+" button -> click Add other.. button -> select GoogleMobileAds.framework and click Open button.

Restart your app then compile and import GoogleMobileAds to your swift view controller

1
  • restarting the app is what did it for me. if it does not work close it and reopen it. gets me every time. Commented Feb 23, 2017 at 5:12
10

There are two steps to solve your problem:

  1. Put the path of GoogleMobileAds.framework in Targets -> Build Settings "Framework Search Path"

  2. Set "No" under Project -> Build Settings -> Enable Bitcode

1
  • Thanks for posting, I updated my Google Ad Mob framework, but never changed the search path. That fixed it!
    – Caimen
    Commented Sep 23, 2015 at 19:59
5

Had this problem. 1st time user of Admob iOS as well.

This is how I solved it.

  1. Go to your Project
  2. Targes
  3. Build Settings
  4. Click 'All' and 'Levels' (so you get the same view as the screenshot)
  5. On 'Search Paths' -> Go to 'Always Search User Paths' and change it to 'Yes' (see the boxed on screenshot) (mine was blank when I did mine)
  6. On 'Framework Search Paths' clicked the option (boxed on screenshot) and add/change the setting to $(inherited)
  7. Clean and Build your App

Steps

Got the solution from this answer: https://stackoverflow.com/a/26445806/2365714

2

you can also install the googlemobileads with cocoa pods. fist install cocoa pods and than add this pod add: pod 'Firebase/AdMob'

in terminal use: pod install

cocoa pods page: https://cocoapods.org here they explain how to use cocoa pops if you don't know how it works

I hope this works (this worked for me)

1

For me the problem was that I didn't add the framework without Copy if necessary checkbox. And I found that, in order to avoid the compiler error, you should check out all the followings:

  • The GoogleMobileAds.framework is located in the project root

  • In Targets | Build Settings | Search Paths | Framework Search Paths, you should find that the list includes $(PROJECT_DIR), and if it doesn't exist, add it manually.

With these settings, you should find the app is compiled successfully.

0

I had this problem in Swift 3.0. I had to update the Googleframeworks to 7.11 which fixed some errors in the main file. I was getting this error though in the testing targets. I made sure that the framework was checked in the Target Membership.

NOTE: Make sure to select the framework and then check the Target Dependency!

enter image description here

I hope it helps.

0

After trying all of the suggested solutions without success, I copied the file GoogleMobileAds.framework to the root folder of the project (same location as xcodeproj file), then added it as explained in other solutions, and it magically built successfully :)

Not the answer you're looking for? Browse other questions tagged or ask your own question.