Linking errors when adding AdMob to IOS cocos2d-x 3.2

user63898 picture user63898 · Jul 19, 2014 · Viewed 9.6k times · Source

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 ?

Answer

Jasio picture Jasio · Jul 31, 2014

-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.2enter image description here

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