6

我创建了一个测试项目来测试 admob 并学习如何使用它,但是当我构建我的项目时,当我尝试将 admob 添加到我的项目中时出现 11 个苹果 mach-o 链接器错误(Xcode 4.3.3)

h文件没问题,这里是M文件(代码取自admob知识库)

#import "chViewController.h"

#define MY_BANNER_UNIT_ID @"my id is written in here"

@interface chViewController ()

@end

@implementation chViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    // Create a view of the standard size at the top of the screen.
    // Available AdSize constants are explained in GADAdSize.h.
    bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

    // Specify the ad's "unit identifier." This is your AdMob Publisher ID.
    bannerView_.adUnitID = MY_BANNER_UNIT_ID;

    // Let the runtime know which UIViewController to restore after taking
    // the user wherever the ad goes and add it to the view hierarchy.
    bannerView_.rootViewController = self;
    [self.view addSubview:bannerView_];

    // Initiate a generic request to load it with an ad.
    [bannerView_ loadRequest:[GADRequest request]];
}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

错误

Undefined symbols for architecture i386:
  "_SCNetworkReachabilityCreateWithName", referenced from:
      -[GADNetworkChecker startNetworkChecking] in libGoogleAdMobAds.a(GADNetworkChecker.o)
  "_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
      -[GADNetworkChecker startNetworkChecking] in libGoogleAdMobAds.a(GADNetworkChecker.o)
  "_SCNetworkReachabilitySetCallback", referenced from:
      -[GADNetworkChecker startNetworkChecking] in libGoogleAdMobAds.a(GADNetworkChecker.o)
  "_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
      -[GADNetworkChecker stopNetworkChecking] in libGoogleAdMobAds.a(GADNetworkChecker.o)
  "_OBJC_CLASS_$_ASIdentifierManager", referenced from:
      objc-class-ref in libGoogleAdMobAds.a(GADIdentifierUtilities.o)
  "_AudioServicesPlaySystemSound", referenced from:
      -[GADWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] in libGoogleAdMobAds.a(GADWebViewDelegate.o)
  "_OBJC_CLASS_$_SKStoreProductViewController", referenced from:
      objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
  "_OBJC_CLASS_$_MFMailComposeViewController", referenced from:
      objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
  "_OBJC_CLASS_$_MFMessageComposeViewController", referenced from:
      objc-class-ref in libGoogleAdMobAds.a(GADOpener.o)
  "_SKStoreProductParameterITunesItemIdentifier", referenced from:
      -[GADOpener openInAppStore:fallbackURLString:] in libGoogleAdMobAds.a(GADOpener.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我已将 lib.googleadmobAds 添加到我的文件夹并将二进制文件与库链接(当我删除它时,我收到相同的错误,但其中 4 个不是 11 个)

我阅读了很多关于它的 stackoveflow 帖子,你们中的一些人说我还需要广告 adsupport.framework 但我找不到它我没有在带有库列表的链接二进制文件中看到它。

网上的这些解决方案都没有工作我被卡住了。

有什么问题我没有收到关于我的 h 或 m 文件的任何错误,那么为什么 mach-o 链接器错误可以帮助我?

4

3 回答 3

14

您需要链接 AdMob 所需的框架。

转到您的目标设置,然后在 Build Phases 中,然后在 Link Binary with Libraries 中并添加以下框架(您可能需要其他框架,这些只是基于我看到的错误):

MessageUI.framework
StoreKit.framework
SystemConfiguration.framework
于 2013-01-23T16:32:57.383 回答
7

这些是我需要添加的框架以使事情顺利进行:

AdSupport.framework
AudioToolbox.framework
MessageUI.framework
SystemConfiguration.framework
StoreKit.framework

我已经有:

UIKit.framework
Foundation.framework
CoreGraphics.framework
libGoogleAdMobAds.a

好的文档是: https ://developers.google.com/mobile-ads-sdk/docs/

于 2013-09-08T17:50:24.070 回答
0

看起来您需要链接到SystemConfiguration框架。

这个Apple 指南应该可以帮助你配置 Xcode 来做到这一点。

于 2013-01-23T16:29:59.110 回答