38

I updated Google AdMob SDK to 7.1.0 using Pods.

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

@import GoogleMobileAds;

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

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

Regards Ranjit

2

20 Answers 20

23

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

enter image description here

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

2
  • 1
    All these answers are so irrelevant! The OP asking about PODS. If you MANUALLY ADDED the framework, pls DO NOT answering this question like it is related.
    – GeneCode
    Commented Oct 15, 2016 at 5:02
  • Wrong answer to the question was the right answer for me. I don't know whether I should agree with @GeneCode. Anyway, +1.
    – Neerkoli
    Commented May 1, 2017 at 12:21
20

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.

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

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

1
  • 2
    This actually helped me! Thanks! I've had a strange bug happening after updating Firebase via cocoapods. Now everything seems to work again. Commented Nov 17, 2017 at 19:47
18

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

0
15

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.framework here, so I removed it and re-added it.

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.

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

That fixed the issue for me.

2
  • I got this problem after adding pods to my project and this solution worked for me. Commented Jan 18, 2018 at 15:20
  • This worked for me. A slightly quicker way is to navigate to your .framework file under Pods in navigator and drag and drop into Link Binary With Libraries.
    – user1300214
    Commented Nov 27, 2020 at 14:01
8

Here is the answer:

Import this into your .m file:

#import <GoogleMobileAds/GADInterstitial.h>
#import <GoogleMobileAds/GADBannerView.h>
2
  • Well, in my case i had to import this: #import <GoogleMobileAds/GADInterstitial.h> #import <GoogleMobileAds/GADBannerView.h>
    – Dasoga
    Commented Apr 19, 2015 at 4:51
  • 4
    @import GoogleMobileAds; is required when using pods @Dasoga. It's essentially the same as #import <GoogleMobileAds/GoogleMobileAds.h>. Also, you can import the entire AdMob framework like so #import <GoogleMobileAds/GoogleMobileAds.h> rather than importing the interstitial files and then the banner files. In addition, you should be importing this and other frameworks/headers in your .h file, not your .m file. Commented Apr 21, 2015 at 13:25
5

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

rm -Rf Pods; pod install

in my project dir.

4

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

4

Here is the solution that worked for me:

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

enter image description here

3

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:

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

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

setting in Xcode UI

0
2

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.

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

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:

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.

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 "+").

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

After this I had no problems with building.

1

For me, the issue was that I hadn't updated my app's "Deployment Target". It was set to < 7.0 which is why it probably was complaining. Once I updated the target to > 7.0, the errors went away. (for future people updating their apps just a few times a year like me)

1

If anyone is still experiencing this same problem, I was just able to find a solution. I spent hours attempting everything that was recommended so far and NOTHING worked, I still don't know what I was doing wrong, but here was a little hack that worked for me: Whatever framework I kept downloading from Google (I tried the manual and Cocoa Pods methods) would not work, but when I just downloaded their little tester xCode project (BannerExample.xcodeproj I believe), I copied the framework that was bundled with that test project, pasted it in my target project file and then added the framework and linked it. After doing this I was able to import the framework just fine and adMob works great. I can't for the life of me figure out what the difference would be, but this did work. I hope this solution might help anyone else dealing with the same problem. I believe I ripped out one of the last five hairs on my head. Good luck!

1

I got the same problem. here is what I did. It worked for me (Hope it helps someone).

  1. copy GoogleMobileAds.framework to somewhere and remove it from pod if you have it.
  2. Add this framework to your project manually( select "copy items if needed"). Check build phases to make sure you have it in "link binary ..." section.
  3. Clear and rebuild it again => success.
0

In case somebody is still occuring this error - check if in build settings field "Framework Search Paths" is filled with correct path to your framework

0
0

Xcode Version 7.2.1 (7C1002) Objective C

I had this problem and had to keep on adding the GoogleMobileAds each time to the project to get rid of this. Not sure if this is a bug. First select the GoogleMobileAds.framework then just untick and tick the Target Membership then try build the error goes away. This worked for me. I hope it helps.

0

Do not unzip lib files under windows, it can not handle symbolic links correctly.

0

I just add "use_frameworks!" in the podfile, update pod and it works. This problem appeared when I updated my OS to El Captain (10.11.15) and XCode to 8 version. My podfile now:

    target 'My Target' do
       use_frameworks!
       pod 'MagicalRecord'
       pod 'AFNetworking'
       pod 'Firebase'
       pod 'Firebase/Core'
       pod 'Firebase/AdMob'
    end
0

I got the same problem. Here is what I did. Hope it helps someone.

  1. Delete GoogleMobileAds.framework from your project (or store it on another folder).
  2. Go to Build Phases, Link Binary with Libraries. Click the + sign for the Link Binary with Libraries section and click Add Other.... Navigate to where you've stored GoogleMobileAds.framework > Versions > A > GoogleMobileAds and open it.

That perfectly fixed the issue for me.

0

I leave a script that generates inject static frameworks

pod --version 1.3.1
Version 9.1 (9B55)

Podfile [Target]

target 'generic' do
    #Google
    pod 'GoogleAds-IMA-iOS-SDK', '~> 3.6.1'
    pod 'Google-Mobile-Ads-SDK', '~> 7.25.0'

    #pod Module 'GoogleMobileAds' not found 
    pod '#LIB_ERROR#'
    sd
end

Podfile [Fuction]

def inject_frameworks(installer, targetName, listPaths)
    def print_info(text)
        puts "\e[33m[!] #{text}\e[0m"
    end

    installer.pods_project.targets.each do |target|
        if target.name == targetName
            print_info "Inject frameworks in #{target.name}"
            config = target.build_configurations.first
            if config
                xcconfig_path = config.base_configuration_reference.real_path
                build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.split(/\s*=\s*/, 2)}.flatten]

                frameworks_paths = Array.new
                if build_settings['FRAMEWORK_SEARCH_PATHS']
                    frameworks_paths.concat(build_settings['FRAMEWORK_SEARCH_PATHS'].delete!("\n").split(/ /))
                end 

                listPaths.each do |frameworks_path|
                    print_info "[#{target.name}] Add search path frameworks #{File.dirname frameworks_path}"
                    frameworks_paths.push(File.dirname frameworks_path)
                end

                build_settings['FRAMEWORK_SEARCH_PATHS'] = frameworks_paths.join(" ")
                File.open(xcconfig_path, "w") { |file| file << "" }
                build_settings.each do |key,value|
                  File.open(xcconfig_path, "a") {|file| file << "#{key} = #{value.strip}\n"}
                end

                listPaths.each do |frameworks_path|
                    print_info "[#{target.name}] Add frameworks #{File.basename frameworks_path}"
                    new_file_framework = config.project.frameworks_group.new_file(frameworks_path)
                    target.frameworks_build_phase.add_file_reference(new_file_framework, true)
                end
            end
        end
    end
end

Podfile [Run Fuction]

post_install do |installer|
    inject_frameworks(installer, "#LIB_ERROR#", [
        '$(PROJECT_DIR)/Google-Mobile-Ads-SDK/Frameworks/frameworks/GoogleMobileAds.framework',
        '$(PROJECT_DIR)/GoogleAds-IMA-iOS-SDK/GoogleInteractiveMediaAds/GoogleInteractiveMediaAds.framework'
    ])
end
0

This sometimes happen when trying not not to use GoogleMobileAds, if this is the case (as me when viewed this): 1- Click the project name. 2- Build settings. 3- Linked Frameworks. 4- Select GoogleMobileAds then the (-) button at the button.

This solved my problem when removing ads from an app template.

Not the answer you're looking for? Browse other questions tagged or ask your own question.