因修改游戏代码,增加admob点击广告监听事件后,发现在iphone4 ios5.1.1下没有捕获到到对应的事件
//点击广告后切换回游戏时
- (void)adViewDidDismissScreen:(GADBannerView *)adView
因此使用的是切出游戏时的事件
- (void)adViewWillLeaveApplication:(GADBannerView *)adView
将sdk升级到最近版本,尝试解决点击广告未触发- (void)adViewDidDismissScreen:(GADBannerView *)adView的问题。
下载地址
http://dl.google.com/googleadmobadssdk/googleadmobadssdkios.zip
解压后发现相比之前用的sdk多了几个头文件,将相关代码拷贝到原来sdk目录下进行覆盖。
clear后build,报错。
(1)错误1
Undefined symbols for architecture armv7:
"CGSizeFromGADAdSize(GADAdSize)", referenced from:
-[iFarmerAppDelegate buildADmobADView] in iFarmerAppDelegate.o
-[iFarmerAppDelegate setAdViewPostion:withY:] in iFarmerAppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
查询相关代码,发现此处报错是因为之前版本与最新版本中的GAD_SIZE相关预定义值发生了变化,之前版本中GAD_SIZE的定义是放在GADBannerView.h中:
// iPhone and iPod Touch ad size.
#define GAD_SIZE_320x50 CGSizeMake(320, 50)
// Medium Rectangle size for the iPad (especially in a UISplitView's left pane).
#define GAD_SIZE_300x250 CGSizeMake(300, 250)
// Full Banner size for the iPad (especially in a UIPopoverController or in
// UIModalPresentationFormSheet).
#define GAD_SIZE_468x60 CGSizeMake(468, 60)
// Leaderboard size for the iPad.
#define GAD_SIZE_728x90 CGSizeMake(728, 90)
而最新版本中增加了一个GADAdSize.h,所有的 GAD_SIZE的定义放到了该头文件中,且内容和之前的也不一样:
#define GAD_SIZE_320x50 CGSizeFromGADAdSize(kGADAdSizeBanner)
#define GAD_SIZE_300x250 CGSizeFromGADAdSize(kGADAdSizeMediumRectangle)
#define GAD_SIZE_468x60 CGSizeFromGADAdSize(kGADAdSizeFullBanner)
#define GAD_SIZE_728x90 CGSizeFromGADAdSize(kGADAdSizeLeaderboard)
#define GAD_SIZE_120x600 CGSizeFromGADAdSize(kGADAdSizeSkyscraper)
因此,最简单的修改方式就是将使用预定义变量的地方直接替换为原来版本中其对应文本即可
(2)错误2
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ASIdentifierManager", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADIdentifierUtilities.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"_OBJC_CLASS_$_ASIdentifierManager", referenced from:
Objc-class-ref in libGoogleAdMobAds.a(GADIdentifierUtilities.o)
Symbol(s) not found for architecture armv7
:Linker command failed with exit code 1 (use -v to see invocation)
查询后发现是缺少了AdSupport.framework,添加后解决该编译错误。
//点击广告后切换回游戏时
- (void)adViewDidDismissScreen:(GADBannerView *)adView
因此使用的是切出游戏时的事件
- (void)adViewWillLeaveApplication:(GADBannerView *)adView
将sdk升级到最近版本,尝试解决点击广告未触发- (void)adViewDidDismissScreen:(GADBannerView *)adView的问题。
下载地址
http://dl.google.com/googleadmobadssdk/googleadmobadssdkios.zip
解压后发现相比之前用的sdk多了几个头文件,将相关代码拷贝到原来sdk目录下进行覆盖。
clear后build,报错。
(1)错误1
Undefined symbols for architecture armv7:
"CGSizeFromGADAdSize(GADAdSize)", referenced from:
-[iFarmerAppDelegate buildADmobADView] in iFarmerAppDelegate.o
-[iFarmerAppDelegate setAdViewPostion:withY:] in iFarmerAppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
查询相关代码,发现此处报错是因为之前版本与最新版本中的GAD_SIZE相关预定义值发生了变化,之前版本中GAD_SIZE的定义是放在GADBannerView.h中:
// iPhone and iPod Touch ad size.
#define GAD_SIZE_320x50 CGSizeMake(320, 50)
// Medium Rectangle size for the iPad (especially in a UISplitView's left pane).
#define GAD_SIZE_300x250 CGSizeMake(300, 250)
// Full Banner size for the iPad (especially in a UIPopoverController or in
// UIModalPresentationFormSheet).
#define GAD_SIZE_468x60 CGSizeMake(468, 60)
// Leaderboard size for the iPad.
#define GAD_SIZE_728x90 CGSizeMake(728, 90)
而最新版本中增加了一个GADAdSize.h,所有的 GAD_SIZE的定义放到了该头文件中,且内容和之前的也不一样:
#define GAD_SIZE_320x50 CGSizeFromGADAdSize(kGADAdSizeBanner)
#define GAD_SIZE_300x250 CGSizeFromGADAdSize(kGADAdSizeMediumRectangle)
#define GAD_SIZE_468x60 CGSizeFromGADAdSize(kGADAdSizeFullBanner)
#define GAD_SIZE_728x90 CGSizeFromGADAdSize(kGADAdSizeLeaderboard)
#define GAD_SIZE_120x600 CGSizeFromGADAdSize(kGADAdSizeSkyscraper)
因此,最简单的修改方式就是将使用预定义变量的地方直接替换为原来版本中其对应文本即可
(2)错误2
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ASIdentifierManager", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADIdentifierUtilities.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
"_OBJC_CLASS_$_ASIdentifierManager", referenced from:
Objc-class-ref in libGoogleAdMobAds.a(GADIdentifierUtilities.o)
Symbol(s) not found for architecture armv7
:Linker command failed with exit code 1 (use -v to see invocation)
查询后发现是缺少了AdSupport.framework,添加后解决该编译错误。