Hari Babu
Hari Babu

Reputation: 921

Admob integration error in iOS (Undefined symbols)

I integrated admob in my project. Added all the framework, other linker flags and Mediation ID.

My code for creating bannerview is:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    CGPoint origin = CGPointMake(self.window.frame.size.height/2 - CGSizeFromGADAdSize(kGADAdSizeBanner).width/2 , 0.0);
    self.m_pBannerView =  [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin];
    self.m_pBannerView.adUnitID = ADMOM_ID_IPHONE;
} else {
    CGPoint origin = CGPointMake(0.0,self.window.frame.size.height -CGSizeFromGADAdSize(kGADAdSizeLeaderboard).height);
    self.m_pBannerView = [[GADBannerView alloc] initWithAdSize:GADAdSizeFromCGSize(CGSizeMake(768, 90)) origin:origin];
    self.m_pBannerView.adUnitID = ADMOB_ID_IPAD;
    
}

self.m_pBannerView.delegate = self;
[self.m_pBannerView setRootViewController:navController_];
[navController_.view addSubview:self.m_pBannerView];
GADRequest * request = [GADRequest request];
[self.m_pBannerView loadRequest:request];
[navController_.view bringSubviewToFront:self.m_pBannerView];

I got the below errors:

Undefined symbols for architecture i386:
"CGSizeFromGADAdSize(GADAdSize)", referenced from:
  -[AppController createBannerAd] in AppDelegate.o
"GADAdSizeFromCGSize(CGSize)", referenced from:
  -[AppController createBannerAd] in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

But the same code working in another project. Now my project have Box2d and Cocos2d.

and I tried with the below code:

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    CGPoint origin = CGPointMake(self.window.frame.size.height/2 - CGSizeFromGADAdSize(kGADAdSizeBanner).width/2 , 0.0);
    self.m_pBannerView =  [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin];
    self.m_pBannerView.adUnitID = ADMOM_ID_IPHONE;
} else {
    CGPoint origin = CGPointMake(0.0,self.window.frame.size.height -CGSizeFromGADAdSize(kGADAdSizeLeaderboard).height);
    self.m_pBannerView = [[GADBannerView alloc] initWithAdSize:GADAdSizeFromCGSize(CGSizeMake(768, 90)) origin:origin];
    self.m_pBannerView.adUnitID = ADMOB_ID_IPAD;
    
}

This time no errors.

Upvotes: 3

Views: 2462

Answers (3)

avuthless
avuthless

Reputation: 996

The errors you get basically say: Missing library!

So, check if both of those projects have same libraries included and include them so: Build Phases -> Link binary with libraries

Upvotes: 1

Muhammad Aamir Ali
Muhammad Aamir Ali

Reputation: 21087

Change the GAD_ ad sizes with:
kGADAdSizeBanner.size.width and kGADAdSizeBanner.size.height

check this

Admob integration issue

Upvotes: 3

Bechir
Bechir

Reputation: 202

You project miss the Admob Library files please follow instructions in the iOS Admob page

Upvotes: 0

Related Questions