Keoros
Keoros

Reputation: 1387

"GoogleMobileAds/GoogleMobileAds.h" file not found error

Recently I tried to update admob SDK(iOS) to the latest version(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

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

enter image description here

I've tried

No luck, any ideas to solve this? thanks.

Upvotes: 10

Views: 34068

Answers (13)

Check that you have google_mobile_ads.framework in the Frameworks section in the General tab of your project target settings.

If not add the framework with the '+' button. It works for my case

enter image description here

Upvotes: 0

Pavel Stepanov
Pavel Stepanov

Reputation: 957

I recently had the same error. It was fixed really easy: I needed to open the .xcworkspace file instead of .xcodeproj.

Also did install pods beforehand but not sure if it contributes to the solution :)

Upvotes: 1

mickeymicks
mickeymicks

Reputation: 669

After several tries, I've finally managed to build my app (from a Unity project). It took several steps from different answers here, so I'm posting the detailed steps of what I did. (I also want to practice formatting skills here in SO. lol)

Overview: The goal is to install admob cocoapod then set the FrameWork paths. Yes, these have already been mentioned above but they come from different answers which was a bit confusing for me.

Steps:

  1. Close Xcode if you have it running.

  2. Open a Terminal window and enter the following:

    sudo gem install cocoapods
    

    This will install cocoapods

  3. In the same Terminal, cd to your Xcode project directory:

    cd Documents/MyGitHub/MyNiceApp
    
  4. Enter the following:

    pod init
    

    This will create a pod file in the project directory

  5. Open the pod file in a text editor and do the following:

    • Uncomment the line for the platform (update the values if necessary)
    • In the section for Pods, add pod 'Google-Mobile-Ads-SDK', '7.26.0'
    • You can specify a version or leave it out to get the latest, like this: pod 'Google-Mobile-Ads-SDK'
    • The File should look something like this:
        # Uncomment the next line to define a global platform for your project
        platform :ios, '9.0'
        
        target 'MyNiceApp-iPhone' do
          # Comment the next line if you don't want to use dynamic frameworks
          use_frameworks!
        
          # Pods for MyNiceApp-iPhone
          pod 'Google-Mobile-Ads-SDK', '7.26.0'
        
          target 'MyNiceApp-iPhone Tests' do
            inherit! :search_paths
            # Pods for testing
          end
        
        end
  1. Back in the Terminal window where you cd'ed to your Xcode project, enter the following:

    pod install --repo-update
    

    This will install the admob framework and save it in your Xcode project directory

  2. Open Xcode with your project or workspace

  3. In Project Explorer, look for Pods > ... > GoogleMobileAds.framework

    Copy the Full Path from the properties, it would look something like this:

    /Users/mickeymicks/Documents/MyGitHub/MyNiceApp/Pods/Google-Mobile-Ads-SDK/Frameworks/frameworks/GoogleMobileAds.framework
    

    Note: the path contains the "GoogleMobileAds.framework" at the end

  4. Open Build Settings for your TARGETS

    Look for Framework Search Paths, double-click then add a new row for it.

    Paste the path you just copied.

  5. Clean the project then Build.

Upvotes: 1

hamza mustafa
hamza mustafa

Reputation: 61

After a days of web scraping i found a solution..You can follow the guide on the google ad mob official page.I have added the link... https://developers.google.com/admob/ios/quick-start#cocoapods

Upvotes: 1

Ted
Ted

Reputation: 23

This worked for me: #import <GoogleMobileAds/GADInterstitialDelegate.h>

Upvotes: -1

Imran Rasheed
Imran Rasheed

Reputation: 956

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

Upvotes: 1

WannaBeHacker
WannaBeHacker

Reputation: 33

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.

Upvotes: 0

Adrian Min
Adrian Min

Reputation: 79

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

Then, in framework you can see


Note:
You must delete Header file first. It's already here in GoogleMobileAds.framework folder.
And useGoogleMobileAds.framework\Versions\A\GoogleMobileAds replace GoogleMobileAds.framework\GoogleMobileAds

Upvotes: 0

Guru
Guru

Reputation: 22042

In Xcode Settings, change below settings

Enable Modules (C and Objective-C)   YES

enter image description here

Upvotes: 2

AndyW
AndyW

Reputation: 1094

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

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

Upvotes: 11

Daniil Bystrov
Daniil Bystrov

Reputation: 302

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

smth like this

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

Upvotes: 0

MAK113
MAK113

Reputation: 1452

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.

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

Upvotes: 2

Ankit Kargathra
Ankit Kargathra

Reputation: 309

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.

Upvotes: 1

Related Questions