Linking errors when adding AdMob to IOS cocos2d-x 3.2
Asked Answered
B

4

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 ?

Beginning answered 19/7, 2014 at 20:38 Comment(8)
I would suggest using plugin-xJorgenson
what do you mean , is there any ready made plugin for admob iOS?Beginning
yes, it's called plugin-x, it comes with cocos2d-x, google it.Jorgenson
plugin-x from what i know its just the definition to make plugins but i didn't found any implementation for adMob for iOSBeginning
github.com/cocos2d-x/plugin-x you dont need to install it manually, it's already inside cocos2d/plugin inside your game's project directory.Jorgenson
there's a sample for AdMob and Flurry thereJorgenson
Thanks i see something ... _admob = dynamic_cast<ProtocolAds*>(PluginManager::getInstance()->loadPlugin("AdsAdmob"));Beginning
does any one know why this problem arises once you add AdMob if it is being referenced to from cocos library ?Zicarelli
E
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
Equitable answered 31/7, 2014 at 16:11 Comment(3)
Thanks Jasio. Just to make it clear, the frameworks should be added in your project, not in cocosFumatorium
Just as a note for those integrating the soomla cocos2dx store framework. This might help too.Alvaalvan
can anyone help me ? i got only 3 of those messages that @Beginning got #53734627Zicarelli
M
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.

Miscreant answered 23/7, 2014 at 4:19 Comment(0)
K
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

Kirschner answered 14/10, 2014 at 23:17 Comment(0)
D
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.

Disjointed answered 24/2, 2015 at 7:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.