简体   繁体   English

iOS 中的 Admob 集成错误(未定义符号)

[英]Admob integration error in iOS (Undefined symbols)

I integrated admob in my project.我在我的项目中集成了 admob。 Added all the framework, other linker flags and Mediation ID.添加了所有框架、其他链接器标志和中介 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.现在我的项目有 Box2d 和 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.这次没有错误。

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

check this检查这个

Admob integration issue Admob 集成问题

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

您的项目错过了 Admob 库文件,请按照iOS Admob 页面中的说明进行操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM