Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AdMob used with iOS 6 crashes the app (unrecognized selector)

I'm using AdMob 6.2.1 in my app which runs under iOS 6 only. I've followed google instructions and everything is working well when running on the simulator and on my iPhone 5.

But, when submitting to Apple the app, i get it refused and the crash log indicates the following:

Last Exception Backtrace:
0   CoreFoundation                  0x3abcb3e2 __exceptionPreprocess + 158
1   libobjc.A.dylib                 0x392d695e objc_exception_throw + 26
2   CoreFoundation                  0x3abcef2c -[NSObject(NSObject) doesNotRecognizeSelector:] + 180
3   CoreFoundation                  0x3abcd648 ___forwarding___ + 388
4   CoreFoundation                  0x3ab25204 _CF_forwarding_prep_0 + 20
5   Dus                             0x000d39f4 -[GADObjectPrivate loadPrivateRequest:autoRefresh:] (GADObjectPrivate.m:402)
6   Dus                             0x000d5454 -[GADObjectPrivate loadRequest:] (GADObjectPrivate.m:827)
7   Dus                             0x000d2f20 -[GADBannerView loadRequest:] (GADBannerView.m:271)
8   Dus                             0x000b57cc -[DMViewController viewDidLoad] (DMViewController.m:131)

I don't understand why it is working for me and crashing with Apple staff.

I had added -ObjC (both to Debug and Release) to Other Linker Flags in Build Settings.

Here is the block code where the crash occurs:

bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin];

bannerView.adUnitID = @"MYBANNERID";
[bannerView setRootViewController:self];
[bannerView setDelegate:self];
bannerView.center = CGPointMake(self.view.center.x, bannerView.center.y);

GADRequest *request = [GADRequest request];

[bannerView loadRequest:request]; //CRASHES HERE
[self.view addSubview:bannerView];

Thank you all for your help.

like image 335
Chakir Avatar asked Dec 08 '25 06:12

Chakir


1 Answers

Place request into ViewDidAppear method.

like image 134
Shmidt Avatar answered Dec 09 '25 19:12

Shmidt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!