iOS中的Admob集成错误

时间:2014-01-23 09:41:40

标签: ios cocos2d-iphone admob box2d iad

我在我的项目中集成了admob。添加了所有框架,其他链接器标志和中介ID。

我创建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;

}

这次没有错误。问题是什么。请告诉我。

3 个答案:

答案 0 :(得分:3)

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

检查这个

Admob integration issue

答案 1 :(得分:0)

你得到的错误主要是说:缺少图书馆!

因此,检查这两个项目是否包含相同的库,并将它们包括在内:构建阶段 - >链接二进制文件库

祝你好运。

答案 2 :(得分:0)

您的项目错过了Admob Library文件,请按照iOS Admob page

中的说明操作