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.
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
There are two steps to solve your problem:
Put the path of GoogleMobileAds.framework
in Targets -> Build Settings "Framework Search Path"
Set "No" under Project -> Build Settings -> Enable Bitcode
Had this problem. 1st time user of Admob iOS as well.
This is how I solved it.
- Go to your Project
- Targes
- Build Settings
- Click 'All' and 'Levels' (so you get the same view as the screenshot)
- 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)
- On 'Framework Search Paths' clicked the option (boxed on screenshot) and add/change the setting to
$(inherited)
- Clean and Build your App
Got the solution from this answer: https://stackoverflow.com/a/26445806/2365714
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)
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.
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!
I hope it helps.
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 :)