在 iOS 中找不到模块“GoogleMobileAds”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29485189/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 05:32:22  来源:igfitidea点击:

Module 'GoogleMobileAds' not found in iOS

iosadmob

提问by Ranjit

I updated Google AdMob SDK to 7.1.0 using Pods.

我使用 Pod 将 Google AdMob SDK 更新到 7.1.0。

So in my appDelegate.m, I am trying to add this line

所以在我的 appDelegate.m 中,我试图添加这一行

@import GoogleMobileAds;

@import GoogleMobileAds;

But I get error saying Module 'GoogleMobileAds' not found.

但我收到错误提示 Module 'GoogleMobileAds' not found

This issue is also present in Interstial Ad example by google on gitHub.

谷歌在 gitHub 上的间隙广告示例中也存在此问题。

Regards Ranjit

问候兰吉特

回答by M Swapnil

Make sure to check "copy item if needed" box when copy GoogleMobileAds.framework to your App.

将 GoogleMobileAds.framework 复制到您的应用时,请务必选中“需要时复制项目”框。

enter image description here

在此处输入图片说明

In my case, I had removed framework and again added that framework and checked that box and issue disappeared.

就我而言,我已经删除了框架并再次添加了该框架并选中了该框,问题就消失了。

回答by kaplya

try to copy your GoogleMobileAds.frameworkinto your root project folder and after that add it to libraries. It works perfectly for me.

尝试将您的GoogleMobileAds.framework项目复制到根项目文件夹中,然后将其添加到库中。它非常适合我。

回答by jason z

I ran into this problem when updating my pods and using Firebase. Unfortunately, none of the answers here helped, so I figured I would post what did work for me.

我在更新 pod 和使用 Firebase 时遇到了这个问题。不幸的是,这里的答案都没有帮助,所以我想我会发布对我有用的东西。

I found a great thread that helped me here. Basically doing the following worked:

我在这里找到了一个对我有帮助的好线程。基本上做了以下工作:

  • Delete my pods - rm -rf Pods
  • Reinstall my pods - pod install --repo-update
  • 删除我的豆荚 - rm -rf Pods
  • 重新安装我的豆荚 - pod install --repo-update

Hope this helps someone because this troubled me for a while.

希望这对某人有所帮助,因为这困扰了我一段时间。

回答by Mark

None of the other answers to date worked for me. This is what did:

迄今为止,其他任何答案都不适合我。这是这样做的:

Go to 'Build Phases', 'Link Binary with Libraries'. I had already added the GoogleMobileAds.frameworkhere, so I removed it and re-added it.

转到“构建阶段”、“将二进制文件与库链接”。我已经在GoogleMobileAds.framework这里添加了,所以我删除了它并重新添加了它。

To add it, click the + sign for the 'Link Binary with Libraries' section and click 'Add Other...'. Navigate to where you've stored GoogleMobileAds.frameworkand select it.

要添加它,请单击“Link Binary with Libraries”部分的 + 号,然后单击“Add Other...”。导航到您存储的位置GoogleMobileAds.framework并选择它。

Make sure you've first added GoogleMobileAds.frameworkto your project by going to 'File' > 'Add Files to your-project-name'.

GoogleMobileAds.framework通过转到“文件”>“将文件添加到您的项目名称”,确保您已首先添加到您的项目中。

That fixed the issue for me.

那为我解决了这个问题。

回答by Dasoga

Here is the answer:

答案如下:

Import this into your .m file:

将其导入您的.m 文件

#import <GoogleMobileAds/GADInterstitial.h>
#import <GoogleMobileAds/GADBannerView.h>

回答by FranMowinckel

I solved setting the "Defines Modules" to YES in the Build Settings and reimporting the Framework.

我解决了在构建设置中将“定义模块”设置为“是”并重新导入框架的问题。

回答by Chaudhry Talha

Here is the solution that worked for me:

Don't Do this
don't do this
Instead of this drag the GoogleMobileAds.frameworkto your project and add all the other frameworks mentioned hereand while drag and drop check copy items if needed.

这是对我有用的解决方案:

要这样做而不是将GoogleMobileAds.framework拖到您的项目中,并添加此处提到的所有其他框架并在需要时拖放检查复制项目。
不要这样做

enter image description here

在此处输入图片说明

回答by Jabson

I deleted pod and install again... SOLVED my problem

我删除了 pod 并重新安装...解决了我的问题

rm -Rf Pods; pod install

in my project dir.

在我的项目目录中。

回答by Bram

The actual issue here is that in the build settings of your app, you are missing the setting:

这里的实际问题是在您的应用程序的构建设置中,您缺少设置:

Framework Search Paths

框架搜索路径

Either edit your project.pbxproj so that BuildSettings includes something like:

编辑您的 project.pbxproj 以便 BuildSettings 包括以下内容:

FRAMEWORK_SEARCH_PATHS = "/Users/bram/src/GoogleMobileAdsSdkiOS-7.16.0/";

Or use Xcode's UI to change the build settings like this:

或者使用 Xcode 的 UI 更改构建设置,如下所示:

setting in Xcode UI

在 Xcode UI 中设置

回答by Roman86

I was stuck with this problem for few hours, but graceful solution is finally found. My method doesn't use "manual files linking", only pure podfile usage.

我被这个问题困扰了几个小时,但终于找到了优雅的解决方案。我的方法不使用“手动文件链接”,只使用纯 podfile。

I faced this problem when I have updated my pods ('pod install' or 'pod update') after adding another target to the project.

在向项目添加另一个目标后更新我的 pod(“pod install”或“pod update”)时,我遇到了这个问题。

My solution is:

我的解决办法是:

Go to your podfile and make sure you have defined "target ..." block for each target of your project(voila! seems like not documented, at least I didn't find it). For example you have 2 targets: "theApp" and "theApp Lite". In this case your pod file must look like this:

转到您的 podfile 并确保您已为项目的每个目标定义了“目标...”块(瞧!似乎没有记录,至少我没有找到)。例如,您有 2 个目标:“theApp”和“theApp Lite”。在这种情况下,您的 pod 文件必须如下所示:

target 'theApp' do
# ...your pods and options here
end

target 'theApp Lite' do
# ...your pods and options here
end

Then do "pod install" or "pod update" to update your libraries.

然后执行“pod install”或“pod update”来更新你的库。

Then go to each target's General settings and make sure you have proper (corresponding to you target) "libPods...a" (or "libPods...framework", in case you use "use_frameworks!" podfile option) file linked under "Linked Frameworks and Libraries" section. Remove garbage/wrong/confused links if any. Add manually if missing (must appear under "Workspace" group/dir when you hit "+").

然后转到每个目标的常规设置并确保您有正确的(对应于您的目标)“libPods...a”(或“libPods...framework”,以防您使用“use_frameworks!”podfile 选项)下链接的文件“链接的框架和库”部分。删除垃圾/错误/混淆的链接(如果有)。如果缺少则手动添加(当您点击“+”时,必须出现在“工作区”组/目录下)。

Under "Build Phases" you should observe "[CP]"-prefixed items for each target.

在“构建阶段”下,您应该观察每个目标的前缀为“[CP]”的项目。

After this I had no problems with building.

在此之后,我的建筑没有问题。