问题
i trying to add AdMob to cocos2d-x 3.2 simple game
using Xcode 5.1 iOS 7.1
i following the tutorials in
https://developers.google.com/mobile-ads-sdk/docs/#ios
and
http://plaincode.blogspot.co.il/2014/02/example-of-admob-integration-in-cocos2d.html
and after adding the -ObjC flag in the "Other Linker Flags"
I'm getting linking errors:
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)
when i removing the -ObjC flag then I'm getting :
<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.
what is wrong here ?
回答1:
-ObjC Loads all members of static archive libraries that implement an Objective-C class or category.(https://developer.apple.com/library/mac/qa/qa1490/_index.html)
In cocos2d-x 3.2
CCController-iOS.mm -> #import <GameController/GameController.h>
UIVideoPlayerIOS.mm ->#import <MediaPlayer/MediaPlayer.h>
so you got those errors.
Solution: Just add following frameworks BuildSettings -> Build Phase -> Link Binary with libraries
MediaPlayer.framework
GameController.framework
回答2:
Yes the reason was -ObjC flag added for AdMob support. I have add MediaPlayer.framework to my project and it solved problems for me.
回答3:
Adding the path to libGoogleAdMobAds.a
in Other Linker Flags
worked for me. Note I'm using Mopub with Cocos2d-x 3.0.
http://discuss.cocos2d-x.org/t/linking-errors-when-adding-admob-to-ios-cocos2d-x-3-2/15672
回答4:
AdMob iOS SDK version 7.0 is released as a framework. You don't need to add -ObjC linker option and extra dependencies if you use it. Also it is optimised for iOS 8.0. If you switch to 7.0 all your linking errors will disappear.
来源:https://stackoverflow.com/questions/24844766/linking-errors-when-adding-admob-to-ios-cocos2d-x-3-2