Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plugin for Google Mobile Ads SDK iOS 7.0.0 #68

Closed
ericleich opened this issue Feb 5, 2015 · 56 comments
Closed

Fix plugin for Google Mobile Ads SDK iOS 7.0.0 #68

ericleich opened this issue Feb 5, 2015 · 56 comments
Assignees

Comments

@ericleich
Copy link
Member

Version 7.0.0 of the iOS SDK breaks the plugin. The imports have changed due to SDK being released as a framework, and it makes use of a couple methods that have been removed/renamed, such as GADAdMobExtras.

@ericleich ericleich self-assigned this Feb 5, 2015
@PAHeartBeat
Copy link

Hi Eric,

I am not XCode or iOS Developer but I face issue as you explain here, to cure that I modified few .h and .m files from unity package iOS Folder as bellow

*File: GADURequest.m*
Old Data for Hader imports for iOS SDK 6.12.2
#import "GADAdMobExtras.h"
#import "GADRequest.h"
#import "GADURequest.h"
change with for iOS SDK 7.0.0

#import "<GoogleMobileAds/GADExtras.h>"
#import "<oogleMobileAds/GADRequest.h>"
#import "GADURequest.h"

and old RequestMethod for iOS SDK 6.12.2
- (GADRequest *)request {
GADRequest *request = [GADRequest request];
request.testDevices = self.testDevices;
request.keywords = self.keywords;
request.birthday = self.birthday;
request.gender = self.gender;
[request tagForChildDirectedTreatment:self.tagForChildDirectedTreatment];
[self.extras setValue:@"1" forKey:@"unity"];
GADAdMobExtras *extras = [[[GADAdMobExtras alloc] init] autorelease];
extras.additionalParameters = self.extras;
[request registerAdNetworkExtras:extras];
return request;
}
with 4th last line change for iOS SDK 7.0.0

- (GADRequest *)request {
GADRequest *request = [GADRequest request];
request.testDevices = self.testDevices;
request.keywords = self.keywords;
request.birthday = self.birthday;
request.gender = self.gender;
[request tagForChildDirectedTreatment:self.tagForChildDirectedTreatment];
[self.extras setValue:@"1" forKey:@"unity"];
GADExtras *extras = [[[GADExtras alloc] init] autorelease];
extras.additionalParameters = self.extras;
[request registerAdNetworkExtras:extras];
return request;
}

File: GADUBanner.m
Old Data for Hader imports for iOS SDK 6.12.2

#import "GADUBanner.h"

#import "GADAdMobExtras.h"
#import "GADAdSize.h"
#import "GADBannerView.h"
#import "GADBannerViewDelegate.h"

Changes with for iOS SDK 7.0.0

#import "GADUBanner.h"
#import "<GoogleMobileAds/GADExtras.h>"
#import "<GoogleMobileAds/GADAdSize.h>"
#import "<GoogleMobileAds/GADBannerView.h>"
#import "<GoogleMobileAds/GADBannerViewDelegate.h>"

But some how My xCode not able to find GADExtras.h file from famework GoogleMobileAds.framework of iOS SDK 7.0.0, in GADURequest.m file, its gave me xcode error like screen shot 2015-02-06 at 11 09 51 am

Can you guide me what I am doing wrong,

~Thanks
Ranpariya Ankur (PAHeartBeat)

@ericleich
Copy link
Member Author

You don't need the quotes around #import <GoogleMobileAds/GADExtras.h>. Another neat trick with the 7.0.0 update is you can just the single line @import GoogleMobileAds; and it'll pull in all the relevant classes for you.

@PAHeartBeat
Copy link

Hi Eric,

Thanks for you valueable feedback, I used first option #import <GoogleMobileAds/GADExtras.h> and it's now it will working.

I have change this files as given bellow

File: GADURequest.m
#import <GoogleMobileAds/GADExtras.h>
#import <GoogleMobileAds/GADRequest.h>
#import "GADURequest.h"

- (GADRequest *)request {
GADRequest *request = [GADRequest request];
request.testDevices = self.testDevices;
request.keywords = self.keywords;
request.birthday = self.birthday;
request.gender = self.gender;
[request tagForChildDirectedTreatment:self.tagForChildDirectedTreatment];
[self.extras setValue:@"1" forKey:@"unity"];
GADExtras *extras = [[[GADExtras alloc] init] autorelease];
extras.additionalParameters = self.extras;
[request registerAdNetworkExtras:extras];
return request;
}

File: GADUBanner.m
`#import "GADUBanner.h"

#import <GoogleMobileAds/GADExtras.h>
#import <GoogleMobileAds/GADAdSize.h>
#import <GoogleMobileAds/GADBannerView.h>
#import <GoogleMobileAds/GADBannerViewDelegate.h>

File: GADUInterstitial.m
#import "GADUInterstitial.h"

#import <GoogleMobileAds/GADExtras.h>
#import <GoogleMobileAds/GADAdSize.h>
#import <GoogleMobileAds/GADInterstitial.h>
#import <GoogleMobileAds/GADInterstitialDelegate.h>

File: GADRequest.h (SDKFolder/GoogleMobileAds.framework/Headers/)
Add this two line and save hader file after @protocol GADAdNetworkExtras; line (without single quote)
// Add this constant to the testDevices property's array to receive test ads on the simulator.
#define GAD_SIMULATOR_ID @"Simulator"

I also made few changes in file GADUInterstitial.m and GADUInterstitial.h to pause unity in backend at time of interstitial is present in screen. (regarding that I have created a new Isssue #69)

Thanks a lot Eric for suggestion for my last comment and reading this long comment on issue.

@mitralone
Copy link

Any progress? If not, can I have link to previous version downloads?

@trungdq88
Copy link

Dear Eric,
Do we have any update? Is there any temporary fix guide for this?

@PAHeartBeat
Copy link

@trungdq88

Please check my last comment, it's currently work for me in Unity 4.6.1p5 (using mono and IL2CPP backend) yet no issue I faced in my test project. this is temp. solution (not offical) for AdMob iOS 7.0.0, otherwise you can use AdMob iOS SDK 6.12.2

@trungdq88
Copy link

@PAHeartBeat
I get this error after following your changes:
screenshot 2015-02-24 20 00 38

Do you have any idea? I am running my project on Unity 4.6.2f1, Xcode 6.1.1, GoogleMobileAdsSdkiOS-7.0.0 and latest release of GoogleMobileAds.unitypackage (v2.1)

@mksbamford
Copy link

@trungdq88 You can fix that by changing it to #import <GoogleMobileAds/GADRequest.h> and moving the Versions/A/Headers folder and Versions/A/GoogleMobileAds file to the root of the SDK directory. (you can remove the rest of the files and folders)

@PAHeartBeat
Copy link

Hi @trungdq88,

That missing file is in side of AdMob iOS SDK (not in Unity Wrapper for AdMob SDK by Gogole). So I think you has forget about add AdMob iOS SDK in your XCode folder.

You have to download iOS SDK from Google AdMob SDK Page and need to add manualy in your xcode proect (exported from your unity project) as instruction given in this link (https://developers.google.com/mobile-ads-sdk/docs/admob/ios/quick-start#manually_using_the_sdk_download)

@trungdq88
Copy link

@PAHeartBeat @xzodia I actually added AdMob iOS SDK, I have just changed the line to #import <GoogleMobileAds/GADRequest.h> and the error is gone but I got a new error:

screenshot 2015-02-25 13 14 00

Looks like a simple syntax error, I tried to put the brackets in several places but could not fix it (I am new to Xcode). Can you help me with that?

@PAHeartBeat
Copy link

Hi @trungdq88,

I not faced this error when I am trying. I just have small guess about it.

I thought you removed this line by mistke
#import "UnityAppController.h"

or you can try this one

Google AdMob Team have updated (may a or two day ago) Unity Wrapper for iOS SDK 7.0.0, may be you are using that one and also implimenting changes which I have suggest.

if you using old AdMob Wrapper which works good witht iOS SDK 6.12.2, please check My test project on GitHub.

In that test project you have to just do one thing after insert iOS SDK 7.0.0. in xcode project open bellow given file and add these two line
File: GADRequest.h (SDKFolder/GoogleMobileAds.framework/Headers/)
Add this two line and save hader file after @protocol GADAdNetworkExtras; line (without single quote)
// Add this constant to the testDevices property's array to receive test ads on the simulator.
#define GAD_SIMULATOR_ID @"Simulator"

@ericleich
Copy link
Member Author

a619273 added support for iOS 7.0.0. Right now you'll need to grab the source files from the repo in Assets/Plugins/iOS, and replace them with the current files in your app.

Also in your Xcode project, you'll want to make sure that "Enable modules" and "Link frameworks automatically" are both set to "Yes" in your build settings.

@trungdq88
Copy link

Thanks everyone,
I am able to build my project now.

@MaraZahidulin
Copy link

Hi.
SDK 7 on XCode 6.1 doesn't work. Have errors:
"umbrella header "GoogleMobileAds.h" not found"
"could not build module GoogleMobileAds"

I did all like you told.
Can you help me please.

@KyDenZ
Copy link

KyDenZ commented Mar 2, 2015

Hello,

I think you have a problem with the emulation ID.
I want to know how to pouur settle this problem, and if once this problem is resolved, the advertising will be functional on all iphones
sans titre-1
sans titre-2

thank you

@siddharth3322
Copy link

I found similar issue using latest admob plugin sdk. I have uploaded image that demonstrate some what my xcode log details.

If I change my admob sdk version to 6.9.2 then it works perfectly on same project.

I am using Unity 4.5.5p3 version to create for xCode build. Also I have used xCode 6.1 installed.
I have tried above all post content in my project but didn't get success in that.

Please give some suggestion where I was doing wrong.

screenshot 2015-03-26 13 29 47

@MaraZahidulin
Copy link

Solution: #77

@ranjitk-plackal
Copy link

Hello All, I am getting error Parse issue:Module 'GoogleMobileAds' not found when I use @import GoogleMobileAds;

I tried using #import <GoogleMobileAds/GADInterstitial.h>, it says file not found. I am using this in appdelegate.m file

Sample app from google for Interstitial also gives the same error.

@rampara
Copy link
Contributor

rampara commented Apr 8, 2015

Have you enabled modules in your project settings?

  • Ram

@ranjitk-plackal
Copy link

yes @rampara .But still its not working

@ranjitk-plackal
Copy link

Hello @ericleich @PAHeartBeat @trungdq88 I am not able to get it working, I am using interstial and banner ads both in my app, if I comment out interstial related code, my app builds properly, but if I uncomment interstitial retlated code, I get error saying Parse issue:Module 'GoogleMobileAds' not found when I use @import GoogleMobileAds; But before this while using SDK 12.12, I used to not get any error. I get error only when I use @import GoogleMobileAds in appDelegate.h file. Otherwise its fine

@malokuS
Copy link

malokuS commented Apr 24, 2015

Hello @ranjitk-plackal ... Did you managed to fix this issue ? - as i have the same problem which is driving me crazy ...

Thanks

malokuS

@ranjitk-plackal
Copy link

I have removed pods completely and I am doing it manually @malokuS

@malokuS
Copy link

malokuS commented Apr 27, 2015

Thank you @ranjitk-plackal , finally managed to get it working.

Best wishes ,

malokuS

@ranjitk-plackal
Copy link

@malokuS weclome, how did you got it working. Please share.

@malokuS
Copy link

malokuS commented Apr 27, 2015

Ok @ranjitk-plackal , this was my case :

I made a game with unity , so what i did was :

  • I re-imported the Google Mobile Ads API's(Folder which is found under : googleads-mobile-plugins/tree/master/unity/source/Assets) and the plugin too , after that in unity I build the xcode project. Then on xcode added the GoogleMobileAds.framework on build phases and switched Enable modules(C and Objective C) to : > yes ... everything is working perfectly now ...

I don't know if you had the same procedure like me , but make sure to import the framework on xcode otherwise soft links can mess up and build will fail.

@ranjitk-plackal
Copy link

@malokuS thanks :)

@malokuS
Copy link

malokuS commented Apr 28, 2015

you're welcome , hopefully it's working for you too @ranjitk-plackal

Best regards ,

malokuS

@Emils72
Copy link

Emils72 commented May 6, 2015

HI all,

I have the same problems . 3 days in a row stuck on this so far.
Just banging the head against the wall... :(
I'm actually using Unity3d 5.0.1.

@malokuS : I'm sorry - I really cannot understand the steps you provided.
Let's see if it matches :

  1. I imported GoogleAdMob unity package 2.2.1 (the latest I found) in unity3d - even though I did not get the part "...re-imported the Google Mobile Ads API's(Folder which is found under : googleads-mobile-plugins/tree/master/unity/source/Assets)..."

  2. Built xCode proj for iOS from Unity

  3. configured the GoogleMobileAds.framework (v7.2.1) in the build phases in xCode

  4. in XCode switched Enable modules(C and Objective C) to : > yes

  5. Run... BAM! Still doesn't work.
    Still have
    ... /Libraries/Plugins/iOS/GADUInterface 1.m:5:9: 'GADRequest.h' file not found
    and
    ... /Libraries/Plugins/iOS/GADUInterstitial.m:9:9: 'GADAdMobExtras.h' file not found

please help me - what am I doing wrong???

@dothanhlam
Copy link

@Emils72 : I am facing the same problem as exactly your. (Unity 5.0.1, GoogleAdMod for Unity 2.2.1, GoogleMobileAds framework 7.2.1). Actually, Google Admob was working well with Unity 4.6.x, GoogleMobileAds 6.12.2 before). I also followed this thread for a month, but it's still impossible to fix this issue.

@rampara
Copy link
Contributor

rampara commented May 6, 2015

@Emils72 @dothanhlam You should not have to re-import the Google Mobile Ads API. We have a quick start for integrating our Unity plugin in linked at https://developers.google.com/mobile-ads-sdk/docs/games#unity. When you say you "configured the GoogleMobileAds.framework (v7.2.1) in the build phases in xCode" are you manually importing the SDK into your Xcode project?

  • Ram

@Emils72
Copy link

Emils72 commented May 7, 2015

Hi rampara, dothanhlam,

thanks for replying.
@rampara see image attached for explanation (this is what I understood...)
what I'm actually doing is to enlist the GoogleMobileAds.framework as per below :

frameworksetup

as a result of adding files... GoogleMobileAds.framework module.

Regards,
Emils

@Emils72
Copy link

Emils72 commented May 7, 2015

@rampara, @dothanhlam
...in the end looks like I almost made it :

  1. I just deleted the googleMobileAds plugin installation in Unity3d (5.0.1) and reinstalled it with latest version 2.2.1.
  2. Then I rebuilt selecting simulator SDK in player settings (otherwise you're going to have static linking problems afterwards in xcode due to libIphone-lib.a compatibility).
  3. Then open up xcode, follow usual instructions
    (add GoogleMobileAds.framework,
    Enable loadmodule in build settings,
    select armv7 arc only,
    in Build Phases under Compile Sources set flag -fno-objc-arc on all "GAD" files).

Et voilà!

now I'm going to understand why it hangs during following simulator execution, but I did it at least through with compiling, it seems... next step to come!

Regards,
Emils.

@dothanhlam
Copy link

@rampara , @Emils72 : I still could not build the project whatever following exact the instruction. I will try the steps from @Emils72 later, but I must temporary remove "Google Admob" for working with another features. Thanks

@mitralone
Copy link

Hello,

I believe you are only doing 1st part of import. There is also a part
where you need to import into xcode and then do the enable .... part.
Importing only to unity will not work.

Tufan
On May 7, 2015 6:55 PM, "Lam Do" notifications@github.com wrote:

@rampara https://github.com/rampara , @Emils72
https://github.com/Emils72 : I still could not build the project
whatever following exact the instruction. I will try the steps from
@Emils72 https://github.com/Emils72 later, but I must temporary remove
"Google Admob" for working with another features. Thanks


Reply to this email directly or view it on GitHub
#68 (comment)
.

@energo
Copy link

energo commented Aug 31, 2015

check my answer.
http://stackoverflow.com/a/32312920/1435700

@vanshikakapoor
Copy link

@rampara @mitralone @dothanhlam
screen shot 2016-02-11 at 12 54 05 pm

I have downloaded the latest unitypackage i.e Google Mobile Ads Unity Plugin v3.0.1 and I am using xcode 7 and unity 5.3.2 but everytime I got the error of GoogleMobileAds not found. Before that I have used 5.1 unity and encounter the same problem. I am attaching the screenshots. Please help.
screen shot 2016-02-11 at 1 02 20 pm

Regards,
Vanshika

@rampara
Copy link
Contributor

rampara commented Feb 12, 2016

If you do not have CocoaPods installed, you will have to manually import the Google Mobile Ads iOS SDK into your Xcode project, as you did in past versions of the plugin.

@vanshikakapoor
Copy link

@rampara

I have already done that. Yet no success. I have added all the frame frameworks and manually imported Google Mobile Ads iOS SDK (GoogleMobileAdsSdkiOS-7.6.0) and followed all the instructions.

Regards,
Vanshika

@siddharth3322
Copy link

@vanshikakapoor, In my game admob ads for iOS working perfectly.
I have this kind of code in GADURequest.m file.

`// Copyright 2014 Google Inc. All Rights Reserved.

@import Foundation;
@import GoogleMobileAds;

#import "GADURequest.h"

@implementation GADURequest

  • (id)init {
    self = [super init];
    if (self) {
    _testDevices = [[NSMutableArray alloc] init];
    _keywords = [[NSMutableArray alloc] init];
    _extras = [[NSMutableDictionary alloc] init];
    }
    return self;
    }
  • (void)addTestDevice:(NSString *)deviceID {
    [self.testDevices addObject:deviceID];
    }
  • (void)addKeyword:(NSString *)keyword {
    [self.keywords addObject:keyword];
    }
  • (void)setBirthdayWithMonth:(NSInteger)month day:(NSInteger)day year:(NSInteger)year {
    NSDateComponents *components = [[NSDateComponents alloc] init];
    components.month = month;
    components.day = day;
    components.year = year;
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    self.birthday = [gregorian dateFromComponents:components];
    }
  • (void)setGenderWithCode:(GADUGender)gender {
    switch (gender) {
    case kGADUGenderMale:
    self.gender = kGADGenderMale;
    break;
    case kGADUGenderFemale:
    self.gender = kGADGenderFemale;
    break;
    default:
    self.gender = kGADGenderUnknown;
    }
    }
  • (void)setExtraWithKey:(NSString *)key value:(NSString *)value {
    [self.extras setValue:value forKey:key];
    }
  • (GADRequest *)request {
    GADRequest *request = [GADRequest request];
    request.testDevices = self.testDevices;
    request.keywords = self.keywords;
    request.birthday = self.birthday;
    request.gender = self.gender;
    request.requestAgent = @"unity";
    [request tagForChildDirectedTreatment:self.tagForChildDirectedTreatment];
    GADExtras *extras = [[GADExtras alloc] init];
    extras.additionalParameters = self.extras;
    [request registerAdNetworkExtras:extras];
    return request;
    }

@end`

I hope this become useful to you.

@rampara
Copy link
Contributor

rampara commented Feb 16, 2016

@vanshikakapoor does the 'framework search paths' setting under build setting include the location of the Google Mobile Ads iOS SDK?

@vanshikakapoor
Copy link

@siddharth3322

My file is same, yet no success.

@siddharth3322
Copy link

@vanshikakapoor, I can help you in this because I have integrated same thing a month ago but at present I am so much busy in game. So when I become free, I post more details regarding my project so that you can compare with yours :)

@vanshikakapoor
Copy link

@siddharth3322 I have integrated Google admobs before 15 days before in my another game, but now its giving me headache.

@rampara I have added the path as well

@siddharth3322
Copy link

@vanshikakapoor, Which other plugins exist into your game?
It totally depend on this as well.

@vanshikakapoor
Copy link

@siddharth3322 Flurry

@siddharth3322
Copy link

@vanshikakapoor, are you getting above image error, right?

@rampara
Copy link
Contributor

rampara commented Feb 22, 2016

@vanshikakapoor If you can provide a link to a Xcode project where this error is reproducible, it can help me investigate further.

@vanshikakapoor
Copy link

@rampara here is my full xcode project. https://www.dropbox.com/s/wpv0regmxsmb6ny/dotiOS.zip?dl=0

@rampara
Copy link
Contributor

rampara commented Feb 25, 2016

@vanshikakapoor your project referenced the Google Mobile Ads framework but did not include it under any of paths listed under 'framework search paths'. Once I added the framework to your project, I was able to build and run without issue. Adding a framework to your Xcode project on newer versions of Xcode will not automatically update your 'framework search paths'. You will have to update your build setting manually, or copy the framework to one of the paths already listed under 'framework search paths'.

@vanshikakapoor
Copy link

@rampara Can you please enlighten me more about this. If you can share some screenshots it will be great help .

@rampara
Copy link
Contributor

rampara commented Feb 25, 2016

The 'framework search paths' set for your target only included the following:

screen shot 2016-02-25 at 11 10 00 am

At those paths, your project did not include the Google Mobile Ads framework. An easy solution would be to remove the framework and re-add it (but ensure to set the 'copy items if needed' setting as shown below)

screen shot 2016-02-25 at 11 12 28 am

@ourangzeb
Copy link

Hi every body i removed the cocoa pods using
https://github.com/CocoaPods/cocoapods-deintegrate

I downloaded the google ad mob framework from 7.7 and then integrate it manually in the iOS project it is working perfect now.

@eholyat
Copy link

eholyat commented Oct 20, 2016

rampara, please deintegrate with cocoapods.

@AnshulPlayBuff
Copy link

@ourangzeb
I am facing a same issue. Can you please provide a link how to integrate google mobile sdk for unity manually.
Thanks

@rampara
Copy link
Contributor

rampara commented May 4, 2017

If you do not want to use Cocoapods (which is the recommended approach for including the GMA SDK) you can include the iOS GMA SDK within the Assets/Plugin/iOS directory of your Unity project or add the framework to the Xcode project generated by Unity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests