2014-01-23 50 views
2

我在我的項目中集成了admob。添加了所有框架,其他鏈接器標誌和調解ID。iOS中的Admob集成錯誤

我創建bannerview代碼:

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]; 

我得到了以下錯誤:

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) 

但相同的代碼在其他項目的工作。現在我的項目有Box2d和Cocos2d。

,我試着用下面的代碼:

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; 

} 

這個時候沒有任何錯誤。問題是什麼。請告訴我。

+0

你想出解決方案的說明? –

+0

不,我仍然遇到同樣的問題。 –

+0

你有沒有想出解決方案@HariBabu?我面臨同樣的錯誤,我嘗試了很多方法,但沒有運氣。 –

回答

0

你得到的錯誤基本上說:缺少庫!

因此,檢查這兩個項目都相同的庫列入,包括他們如此:構建階段 - >鏈接二進制與圖書館

好運。

+0

我添加了相同的庫。但仍然是同樣的問題。 –

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

檢查這個

Admob integration issue