AdMob 7.3.1 and Swift 2.0 - Module not found

China☆狼群 提交于 2019-12-17 18:56:53

问题


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:


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




回答2:


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




回答3:


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

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




回答4:


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)




回答5:


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.




回答6:


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.




回答7:


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 :)



来源:https://stackoverflow.com/questions/30876363/admob-7-3-1-and-swift-2-0-module-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!