简体   繁体   English

在cocos2d-x项目中将admob与Objective-C一起使用时的问题

[英]Problems when use admob with objective-c in a cocos2d-x project

I use pod to initialize my project and trying to add a banner on my cocos game. 我使用pod初始化我的项目,并尝试在我的cocos游戏中添加横幅。 I have already finish the game but whenever I use the "adBanner" in the function : didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 我已经完成游戏了,但是每当我在函数中使用“ adBanner”时:didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

I got the linking problem. 我遇到了链接问题。 Can anyone help? 有人可以帮忙吗?

![enter image description here][1] ![在此处输入图片描述] [1]

Error information: 错误信息:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_GADBannerView", referenced from:
      objc-class-ref in AppController.o
  "_kGADAdSizeBanner", referenced from:
      -[AppController application:didFinishLaunchingWithOptions:] in AppController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Code: 码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    // Override point for customization after application launch.

    // Add the view controller's view to the window and display.
    window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];

    // Use RootViewController to manage CCEAGLView
    _viewController = [[RootViewController alloc]init];
    _viewController.wantsFullScreenLayout = YES;


    // Set RootViewController to window
    if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
    {
        // warning: addSubView doesn't work on iOS6
        [window addSubview: _viewController.view];
    }
    else
    {
        // use this method on ios6
        [window setRootViewController:_viewController];
    }

    [window makeKeyAndVisible];

    [[UIApplication sharedApplication] setStatusBarHidden:true];

    //==============================banner================================
    CGPoint origin = CGPointMake(0.0, _viewController.view.frame.size.height - kGADAdSizeBanner.size.height);
    self.adBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin];
    self.adBanner.adUnitID = @"ca-app-pub-3940256099942544/2934735716";


    //==============================banner================================

In Build Settings - > Linking . 在Build Settings-> Linking中。 Find "Other Linker Flags". 找到“其他链接器标志”。 Set -Objc for build and release. 设置-Objc以进行构建和发布。

Make sure all other frameworks are set correct as per admob docs. 确保根据admob文档正确设置所有其他框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM