user1453351
user1453351

Reputation:

Google AdMob 7 integration with cocoapods

I have spent hours on this and still no luck.

I have a library (which is a pod) and it's using Google AdMob 7 as a dependency, let's say that it's named MyLib

Now when I want to add pod 'MyLib' to project A, it'll install it alongside its dependencies which include Google AdMob 7.

The problem is: When I test the library project which contains its source files, it works just fine but when I compile project A, it doesn't compile and it gives me a compiler error on the import line

@import GoogleMobileAds;

which is in the MyLib source files.

To make it simpler

Project -> Contains a pod I wrote which is MyLib -> Using AdMob 7 as a pod

Any idea why it's happening?

EDIT:

If anyone is interested, the same now happens with Google maps after they converted it to a Framework

Upvotes: 4

Views: 1684

Answers (2)

malhal
malhal

Reputation: 30569

There are two duplicate Google Ad Pods in Cocoa Pods:

GoogleMobileAds 20MB and contains only the framework

Google-Mobile-Ads-SDK 40MB contains the framework, samples and documentation.

Someone should update the cocoa pods description to make this clear rather than having the exact same Google Ad SDK description for both pods, which is really confusing.

Using the first pod containing the framework should solve your problem and import like this:

#import <GoogleMobileAds/GoogleMobileAds.h>

Upvotes: 3

user1453351
user1453351

Reputation:

If anyone is interested or faced this problem, I know now why my end-point application couldn't notice the existence of Google Ad Mob pod inside my own pod.

I should have used spec.ios.vendored_frameworks in my pod spec cause now Google AdMob SDK and Maps SDK for iOS are provided as Frameworks in cocoapods so simply I added this to my pod spec for the library I wrote:

s.ios.vendored_frameworks = 'Pods/Google-Maps-iOS-SDK/GoogleMaps.framework', 'Pods/Google-Mobile-Ads-SDK/GoogleMobileAdsSdkiOS-7.0.0/GoogleMobileAds.framework'

Upvotes: 4

Related Questions