我试图将AdMob添加到cocos2d-x 3.2简单游戏中
使用Xcode 5.1 iOS 7.1
我遵循教程
https://developers.google.com/mobile-ads-sdk/docs/#ios
和
http://plaincode.blogspot.co.il/2014/02/example-of-admob-integration-in-cocos2d.html
并在"其他链接标志中添加-ObjC标志"
我收到错误链接:
Undefined symbols for architecture armv7s:
"_GCControllerDidDisconnectNotification", referenced from:
-[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)
"_GCControllerDidConnectNotification", referenced from:
-[GCControllerConnectionEventHandler observerConnection:disconnection:] in libcocos2dx iOS.a(CCController-iOS.o)
"_OBJC_CLASS_$_MPMoviePlayerController", referenced from:
objc-class-ref in libcocos2dx iOS.a(UIVideoPlayerIOS.o)
"_OBJC_CLASS_$_GCController", referenced from:
objc-class-ref in libcocos2dx iOS.a(CCController-iOS.o)
(maybe you meant: _OBJC_CLASS_$_GCControllerConnectionEventHandler)
"_MPMoviePlayerPlaybackStateDidChangeNotification", referenced from:
-[UIVideoViewWrapperIos dealloc] in libcocos2dx iOS.a(UIVideoPlayerIOS.o)
-[UIVideoViewWrapperIos setURL::] in libcocos2dx iOS.a(UIVideoPlayerIOS.o)
"_MPMoviePlayerPlaybackDidFinishNotification", referenced from:
-[UIVideoViewWrapperIos dealloc] in libcocos2dx iOS.a(UIVideoPlayerIOS.o)
-[UIVideoViewWrapperIos setURL::] in libcocos2dx iOS.a(UIVideoPlayerIOS.o)
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
当我删除-ObjC标志时 然后我得到了:
<Google> Category methods are not loaded. Make sure you link the Google Mobile Ads library using one of the -ObjC, -force_load, or -all_load linker flags. See https://developers.google.com/mobile-ads-sdk/docs/#ios for more information.
这里有什么问题?
答案 0 :(得分:29)
-ObjC 加载实现Objective-C类或类别的静态归档库的所有成员。(https://developer.apple.com/library/mac/qa/qa1490/_index.html)
在cocos2d-x 3.2
中 CCController-iOS.mm - &gt; #import <GameController/GameController.h>
UIVideoPlayerIOS.mm - &gt; #import <MediaPlayer/MediaPlayer.h>
所以你得到了那些错误。
<强>解决方案:强> 只需添加以下框架BuildSettings - &gt;构建阶段 - &gt;链接二进制文件库
MediaPlayer.framework
GameController.framework
答案 1 :(得分:1)
是的,原因是为AdMob支持添加了-ObjC标志。我已将MediaPlayer.framework添加到我的项目中,它为我解决了问题。
答案 2 :(得分:0)
在libGoogleAdMobAds.a
中添加Other Linker Flags
的路径为我工作。注意我使用Mopub和Cocos2d-x 3.0。
http://discuss.cocos2d-x.org/t/linking-errors-when-adding-admob-to-ios-cocos2d-x-3-2/15672
答案 3 :(得分:0)
AdMob iOS SDK 7.0版作为框架发布。如果使用它,则无需添加-ObjC链接器选项和额外依赖项。它还针对iOS 8.0进行了优化。如果切换到7.0,则所有链接错误都将消失。