简体   繁体   中英

I am getting a Mach-O linker error in the below AdMob Code. Can someone please help me with simple Admob for iPhone?

In this code i have added Google AdmobSDK in my Xcode project and tried to display an ad. But i am not quite sure if this code does really work!

AdmobiPhoneViewController.m

#import "AdmobiPhoneViewController.h"
#define AdMob_ID @"a151120ca07fb81"

@implementation AdmobiPhoneViewController


- (void)dealloc
{
    AdMob.delegate = nil;
    [AdMob release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{

Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning];

Release any cached data, images, etc that aren't in use. } #pragma mark – View lifecycle //Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

- (void)viewDidLoad
{
    [super viewDidLoad];

    AdMob = [[GADBannerView alloc]
         initWithFrame:CGRectMake(0.0, self.view.frame.size.height -
                                  GAD_SIZE_320x50.height,
                                  GAD_SIZE_320x50.width,
                                  GAD_SIZE_320x50.height)];

    AdMob.adUnitID = AdMob_ID;
    AdMob.rootViewController = self;
    [self.view addSubview:AdMob];


    GADRequest *r = [[GADRequest alloc] init];
    r.testing = YES;
   [AdMob loadRequest:r];

}
- (void)viewDidUnload
{
    [super viewDidUnload];
    //Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
 (UIInterfaceOrientation)interfaceOrientation
{
     //Return YES for supported orientations
     return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end

You can check out the latest AdMob sample projects here .

If you're using the latest AdMob SDK, you only need the ObjC linker flag; you no longer need -all_load .

EDIT:

If you are using libraries that still require the -all_load flag, you can instead pass -force_load path/to/library.a to load only that library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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