ios “GoogleMobileAds/GoogleMobileAds.h”文件未找到错误

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

"GoogleMobileAds/GoogleMobileAds.h" file not found error

iosadmob

提问by Keoros

Recently I tried to update admob SDK(iOS) to the latest version(7.0.0)

最近我尝试将 admob SDK(iOS) 更新到最新版本 (7.0.0)

I have trouble importing the framework. enter image description here

我在导入框架时遇到问题。 在此处输入图片说明

It keeps giving me this error "GoogleMobileAds/GoogleMobileAds.h" file not found

它不断给我这个错误 "GoogleMobileAds/GoogleMobileAds.h" file not found

I removed the old admob sdk and imported the framework manually.

我删除了旧的 admob sdk 并手动导入了框架。

enter image description here

在此处输入图片说明

I've tried

我试过了

  • restart xcode
  • cleaning the project (command + shift + k)
  • remove the framework and add it again
  • 重启xcode
  • 清理项目(command + shift + k)
  • 删除框架并再次添加

No luck, any ideas to solve this? thanks.

没有运气,有什么想法可以解决这个问题吗?谢谢。

回答by AndyW

Answer is to change the 'Framework Search Paths' build setting to the folder where your 'GoogleMobileAds.framework' is located.

答案是将“框架搜索路径”构建设置更改为“GoogleMobileAds.framework”所在的文件夹。

Full steps I did to solve:

我解决的完整步骤:

  • Remove references to the framework from project navigator

  • Click on your project in the project navigator, then on your project under 'TARGETS', then click 'Build Phases'

  • Expand 'Link Binary With Libraries'

  • Select 'GoogleMobileAds.framework' and click the '-' (if it's there)

  • Click the '+'

  • Click 'Add Other...', find and select 'GoogleMobileAds.framework' and click 'Open'

  • The google ads framework should now be in the list

  • Click 'Build Settings'

  • Change 'Framework Search Paths' to the folder where your 'GoogleMobileAds.framework' is located

  • Clean and re-build project

  • 从项目导航器中删除对框架的引用

  • 在项目导航器中单击您的项目,然后单击“目标”下的项目,然后单击“构建阶段”

  • 展开“链接二进制与库”

  • 选择“GoogleMobileAds.framework”并点击“-”(如果有)

  • 点击“+”

  • 点击“添加其他...”,找到并选择“GoogleMobileAds.framework”,然后点击“打开”

  • 谷歌广告框架现在应该在列表中

  • 单击“构建设置”

  • 将“框架搜索路径”更改为“GoogleMobileAds.framework”所在的文件夹

  • 清理并重新构建项目

回答by Guru

In Xcode Settings, change below settings

在 Xcode 设置中,更改以下设置

Enable Modules (C and Objective-C)   YES

enter image description here

在此处输入图片说明

回答by MAC113

Right click on framework --> show in finder --> Delete framework from that place.--> go to the project and see at your framework place , its in red color .

右键单击框架--> 在查找器中显示--> 从该位置删除框架。--> 转到项目并查看您的框架位置,它是红色的。

Again right click on that and delete it. Again run project and save project . i know the build not successful.

再次右键单击并删除它。再次运行 project 并保存 project 。我知道构建不成功。

Again add the framework and then run before that clean your project.

再次添加框架,然后在清理项目之前运行。

回答by Ankit Kargathra

don't drag framework in your project.. just only copy past in your project folder and add files TO in your project..

不要在您的项目中拖动框架.. 只需在您的项目文件夹中复制过去并将文件添加到您的项目中..

i think it'enter image description heres 100% working.

我认为它在此处输入图片说明100% 有效。

回答by Daniil Bystrov

Looks like they have some specific dependences and must be added to folder where is located .xcodeproj

看起来它们有一些特定的依赖关系,必须添加到 .xcodeproj 所在的文件夹中

smth like this

像这样

this is actual for modulimport and without pods: @import GoogleMobileAds;

这是模块导入和没有 pod 的实际情况:@import GoogleMobileAds;

回答by Adrian Min

I have tried to put the GoogleMobileAds.framework\Versions\A\Headersfolder to GoogleMobileAds.frameworkfolder and it worked for me.

我试图将GoogleMobileAds.framework\Versions\A\Headers文件GoogleMobileAds.framework夹放入文件夹,它对我有用。

Then, in framework you can see

然后,在框架中你可以看到



Note:
You must delete Headerfile first. It's already here in GoogleMobileAds.frameworkfolder.
And useGoogleMobileAds.framework\Versions\A\GoogleMobileAdsreplace GoogleMobileAds.framework\GoogleMobileAds

注意:
必须先删除Header文件。它已经在GoogleMobileAds.framework文件夹中了。
并使用GoogleMobileAds.framework\Versions\A\GoogleMobileAds替换GoogleMobileAds.framework\GoogleMobileAds

回答by WannaBeHacker

I am manually dragging the AdMob SDK into my project and was getting this error. Ultimately what worked was I dragged the SDK files into my projects folder on the computer (for me it was: Users/aaronfrom/documents/projectname) when asked to replace files I said yes. It then worked. I think that this is where my framework search path was directed towares and I needed to update the files in the project folder on my computer, it had nothing to do with settings in Xcode.

我手动将 AdMob SDK 拖到我的项目中,但出现此错误。最终,当被要求替换文件时,我将 SDK 文件拖到计算机上的项目文件夹中(对我来说是:Users/aaronfrom/documents/projectname),我说是。然后它起作用了。我认为这是我的框架搜索路径指向软件的地方,我需要更新计算机上项目文件夹中的文件,这与 Xcode 中的设置无关。

回答by Imran Rasheed

This is the Solution

这是解决方案

 #1 Open Terminal install Cocoapods -> $ sudo gem install cocoapods
 #2 Open Terminal and Enter Path of Your Directory -> cd desktop/gamebuild
 #3 Enter this on Terminal -> Pod Init
 #4 Go To Directory Paste This Line in Podfile -> pod 'Google-Mobile-Ads-SDK'
 #5 Close File and Enter this on Terminal-> Pod install