I have created a test project to test admob and leaarn how to use it but when I build my project I get 11 apple mach-o linker errors when I try to add admob into my project(Xcode 4.3.3)
The h file is oke and here is M file(codes are taken from admob knowlage base)
#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.
}
Errors
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)
I have added lib.googleadmobAds to my folder and linked binary with libraries(when I remove it I receive same errors but 4 of them not 11)
I read lots of stackoveflow posts about it and some of you saying that I need also need to ad adsupport.framework but I cant find it I dont see it in the link binaries with libraries list.
None of these solutions on net is working I am stuck.
What is wrong with it I am not receiving any erros about my h or m files so why mach-o linker errors can somebody help me please ?
You need to link against the frameworks that AdMob requires.
Go to your target settings, then in Build Phases, then in Link Binary with Libraries and add the following frameworks (you may need additional ones, these are juste based on the errors I see):
MessageUI.framework
StoreKit.framework
SystemConfiguration.framework
These are the frameworks that I need to add to get thing going:
AdSupport.framework
AudioToolbox.framework
MessageUI.framework
SystemConfiguration.framework
StoreKit.framework
I already had:
UIKit.framework
Foundation.framework
CoreGraphics.framework
libGoogleAdMobAds.a
Good Documentation is: https://developers.google.com/mobile-ads-sdk/docs/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With