xcode 如何将 AdMob 集成到 iOS 应用中?其他教程似乎不适用于最新更新
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35237593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I integrate AdMob into an iOS app? Other tutorials do not seem to work with the latest updates
提问by Gautham Ganesh Elango
I am trying to integrate Google`s AdMob into my iOS app, using Xcode 7.2, Swift 2.0, and iOS 9.2. I followed the official tutorial on this: https://developers.google.com/admob/ios/quick-start; and I have tried both methods: the streamlined method with CocoaPods, and manually using the SDK download.
我正在尝试使用 Xcode 7.2、Swift 2.0 和 iOS 9.2 将 Google 的 AdMob 集成到我的 iOS 应用程序中。我遵循了官方教程:https: //developers.google.com/admob/ios/quick-start;我已经尝试了两种方法:使用 CocoaPods 的简化方法,以及手动使用 SDK 下载。
In the streamlined method, I had a lot of trouble with CocoaPods, which nearly destroyed my entire Xcode project. This experience made me never use CocoaPods again. Unless you know a lot on CocoaPods, do not ask me to use them.
在精简的方法中,我用 CocoaPods 遇到了很多麻烦,几乎毁掉了我的整个 Xcode 项目。这次经历让我再也没有使用过 CocoaPods。除非你对 CocoaPods 了解很多,否则不要让我使用它们。
In the manual method, I am unable to import the framework into my code, although it is imported already into the project. I get the error: No such module 'GoogleMobileAds'. The framework is visible in the Project Navigator with other frameworks, in the Linked Frameworks and Libraries with other frameworks.
在手动方法中,我无法将框架导入到我的代码中,尽管它已经导入到项目中。我收到错误消息:没有这样的模块“GoogleMobileAds”。该框架在项目导航器中与其他框架可见,在链接框架和库中与其他框架可见。
Due to this I am unable to use all of the code listed in the tutorial, and I have no code to show. If you are looking for any code related to integrating AdMob, it is in the tutorial. Please note I am a beginner in Swift, and I have no knowledge in Objective-C. Thanks.
由于这个原因,我无法使用教程中列出的所有代码,而且我没有代码可以显示。如果您正在寻找与集成 AdMob 相关的任何代码,请参阅教程。请注意,我是 Swift 的初学者,我对 Objective-C 一无所知。谢谢。
import GoogleMobileAds
回答by Gautham Ganesh Elango
Figured out the solution myself. I noticed that in the tutorial, there was an important section I promptly ignored:
自己想出了解决办法。我注意到在教程中,有一个重要的部分我很快就忽略了:
Add other frameworks that the SDK requires
The SDK depends on the following iOS development frameworks which may not already be part of your project:
AdSupport
AudioToolbox
AVFoundation
CoreGraphics
CoreMedia
CoreTelephony
EventKit
EventKitUI
MediaPlayer
MessageUI
StoreKit
SystemConfiguration
添加 SDK 需要
的其他框架SDK 依赖于以下 iOS 开发框架,这些框架可能尚未包含在您的项目中:
AdSupport
AudioToolbox
AVFoundation
CoreGraphics
CoreMedia
CoreTelephony
EventKit
EventKitUI
MediaPlayer
MessageUI
StoreKit
SystemConfiguration
You must make sure these frameworks are already part of the project, since Admob depends on them. If anyone else is having similar issues as described above, try this, or read the tutorialcarefully.
您必须确保这些框架已经是项目的一部分,因为 Admob 依赖于它们。如果其他人遇到与上述类似的问题,请尝试此操作,或仔细阅读教程。
回答by viratpuar
There are two steps to solve your problem:
有两个步骤可以解决您的问题:
Put the path of GoogleMobileAds.framework in Targets -> Build Settings "Framework Search Path"
将 GoogleMobileAds.framework 的路径放在 Targets -> Build Settings "Framework Search Path"
Set "No" under Project -> Build Settings -> Enable Bitcode
在 Project -> Build Settings -> Enable Bitcode 下设置“ No”
refer this Link
参考这个链接