6

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 ?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
user63898
  • 29,839
  • 85
  • 272
  • 514

4 Answers4

31

-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
Jasio
  • 491
  • 3
  • 9
  • Thanks Jasio. Just to make it clear, the frameworks should be added in your project, not in cocos – Alex R. R. Oct 16 '14 at 10:42
  • 1
    Just as a note for those integrating the soomla cocos2dx store framework. This might help too. – quik_silv Oct 21 '14 at 05:07
  • can anyone help me ? i got only 3 of those messages that @user63898 got https://stackoverflow.com/questions/53734127/what-is-other-linker-flags-in-xcode-build-settings – isJulian00 Dec 12 '18 at 00:47
1

Yes the reason was -ObjC flag added for AdMob support. I have add MediaPlayer.framework to my project and it solved problems for me.

Narek
  • 38,779
  • 79
  • 233
  • 389
0

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

SundayMonday
  • 19,147
  • 29
  • 100
  • 154
0

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.

Dmitry
  • 419
  • 3
  • 9