objective-c - 将 AdMob 添加到 IOS cocos2d-x 3.2 时出现链接错误

标签 objective-c admob cocos2d-x cocos2d-x-3.0

我正在尝试将 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

并在“其他链接器标志”中添加 -Objcflags后

我收到链接错误:

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)

当我删除 -Objcflags时 然后我得到:

<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.

这里有什么问题吗?

最佳答案

-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)

在 cocos2d-x 3.2 enter image description here

CCController-iOS.mm -> #import <GameController/GameController.h>
UIVideoPlayerIOS.mm -> #import <MediaPlayer/MediaPlayer.h>

所以你得到了那些错误。

解决方案: 只需添加以下框架 BuildSettings -> Build Phase -> Link Binary with libraries

MediaPlayer.framework
GameController.framework

关于objective-c - 将 AdMob 添加到 IOS cocos2d-x 3.2 时出现链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24844766/

相关文章:

ios - 播放声音无延迟 iOS

ios - 在由步进器控制的单元格中设置标签 - objective-c

iphone - 如何更改 UINavigationBar backButton 项上的文本?

android - 如何为 Android 创建 DFP 原生广告单元 ID

ios - 谷歌admob ios : Request Error: No ad to show

java - Google Play 服务上的广告声明在 APK 中显示 Admob

android - 在android中改变位图中的蓝色和红色 channel

c++ - Cocos2Dx "use of undeclared identifier"iOS游戏内购

ios - 如何使 iOS 7 下的 UISwitch 不采用其背后 View 的背景颜色?

android - ndk-gdb 找不到 gdb.setup 但 x86 下有