Admob Linker Error
I'm implementing Admob to my iphone app. It开发者_StackOverflow works in the simulator at iOS 4.0 (with target SDK 3.0), which shows I've correctly followed the beginners tutorial at http://code.google.com/mobile/ads/docs/ios/fundamentals.html. However when trying to run on a device which has iOS 4.3.1 I get 2 linker errors:
ld: warning: ignoring file /Users/home/Documents/iPhoneDocs/Admobs/googleadmobadssdkios/GoogleAdMobAdsSDK/libGoogleAdMobAds.a, file was built for unsupported file format which is not the architecture being linked (armv7) Undefined symbols for architecture armv7: "_OBJC_CLASS_$_GADRequest", referenced from: objc-class-ref in RootViewController.o "_OBJC_CLASS_$_GADBannerView", referenced from: objc-class-ref in RootViewController.o ld: symbol(s) not found for architecture armv7 collect2: ld returned 1 exit status
What does this mean and how do I fix it? One thing I don't understand is that the file it's referencing is valid, but I was expecting it to reference the one in my project directory.
You need to add libGoogleAdMobAds.a to framework. Drag libGoogleAdMobAds.a to Link Binary With Libraries. Check following image
http://code.google.com/mobile/ads/images/frameworks2.png
For those who are getting this error when trying to use AdMob through CocoaPods the answer is to include the libGoogleAdMobAds.a library to the Pod (specifically Pods-AdMob). It seems that's not added automatically.
edit: Some more detail - you need to go into the Pods project, Build Phases, choose the Ad Mob library, then in link binary with Libraries press the + button, choose Add Other..., then navigate to the Pod directory and the Google Ad Mob directory within there, then add the libGoogleAdMobAds.a file.
It happen to me when I try to implement AdMob on my project. I was using Xcode 6, build target iOS 6.0. After trying to fix it. I found that It missing:
-lGoogleAdMobAds
in Other linker flags.
So the step are:
- Press cmd + 1
- Selected App Target (not Pods)
- Goto Build Settings -> Other Linker Flags
- Add "-lGoogleAdMobAds" (without ")
Hope the problem solve.
精彩评论