[英]Can someone help me fix this error in Swift "Apple Mach-O Linker Error?
[英]I am getting a Mach-O linker error in the below AdMob Code. Can someone please help me with simple Admob for iPhone?
在此代码中,我在Xcode项目中添加了Google AdmobSDK,并试图显示广告。 但是我不太确定这段代码是否真的有效!
AdmobiPhoneViewController.m
#import "AdmobiPhoneViewController.h"
#define AdMob_ID @"a151120ca07fb81"
@implementation AdmobiPhoneViewController
- (void)dealloc
{
AdMob.delegate = nil;
[AdMob release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
如果没有超级视图,则释放视图。 [super didReceiveMemoryWarning];
释放所有未使用的缓存数据,图像等。 } #pragma mark –视图生命周期//加载viewDidLoad以在加载视图后进行附加设置,通常是从笔尖进行。
- (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
您可以在此处查看最新的AdMob示例项目。
如果您使用的是最新的AdMob SDK,则只需要ObjC
链接器标志; 您不再需要-all_load
。
编辑:
如果使用的库仍需要-all_load
标志,则可以改为传递-force_load path/to/library.a
以仅加载该库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.