【问题标题】:Linking errors when adding AdMob to IOS cocos2d-x 3.2IOS cocos2d-x 3.2添加AdMob时链接错误
【发布时间】:2014-09-10 18:11:54
【问题描述】:

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

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

我收到链接错误:

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)

当我删除 -ObjC 标志时 然后我得到:

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

这里有什么问题?

【问题讨论】:

  • 我建议使用 plugin-x
  • 什么意思,有没有现成的admob iOS插件?
  • 是的,它叫plugin-x,它自带cocos2d-x,google一下。
  • plugin-x 据我所知,它只是制作插件的定义,但我没有找到适用于 iOS 的 adMob 的任何实现
  • 那里有 AdMob 和 Flurry 的示例

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


【解决方案1】:

是的,原因是为 AdMob 支持添加了 -ObjC 标志。我已将 MediaPlayer.framework 添加到我的项目中,它为我解决了问题。

【讨论】:

    【解决方案2】:

    -ObjC 加载实现 Objective-C 类或类别的静态存档库的所有成员。(https://developer.apple.com/library/mac/qa/qa1490/_index.html)

    在 cocos2d-x 3.2

    CCController-iOS.mm -> #import &lt;GameController/GameController.h&gt;
    UIVideoPlayerIOS.mm ->#import &lt;MediaPlayer/MediaPlayer.h&gt;

    所以你得到了这些错误。

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

    MediaPlayer.framework
    GameController.framework
    

    【讨论】:

    • 谢谢贾西奥。只是说清楚,框架应该添加到你的项目中,而不是在 cocos 中
    • 对于那些集成了 soomla cocos2dx 存储框架的人来说是一个注释。这也可能有帮助。
    • 谁能帮助我?我只收到了@user63898 收到的 3 条消息stackoverflow.com/questions/53734127/…
    【解决方案3】:

    Other Linker Flags 中添加libGoogleAdMobAds.a 的路径对我有用。注意我在 Cocos2d-x 3.0 中使用 Mopub。

    http://discuss.cocos2d-x.org/t/linking-errors-when-adding-admob-to-ios-cocos2d-x-3-2/15672

    【讨论】:

      【解决方案4】:

      AdMob iOS SDK 7.0 版作为框架发布。如果使用它,则不需要添加 -ObjC 链接器选项和额外的依赖项。它还针对 iOS 8.0 进行了优化。如果切换到 7.0,所有链接错误都会消失。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多