錯誤1. Undefined symbols for architecture i386:
"_OBJC_CLASS_$_ASIdentifierManager", referenced from:
objc-class-ref in libGoogleAdMobAds.a(GADIdentifierUtilities.o)
"_OBJC_CLASS_$_SKStoreProductViewController", 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)
除了《Google AdMob 廣告 iOS 初級指南》(https://developers.google.com/mobile-ads-sdk/docs/ios/fundamentals?hl=zh-cn,此文篇后的最佳實踐值得一看 )中所列出的幾個lib需加入外,還需要加入AdSupport、StoreKit兩個庫
錯誤2. [GADObjectPrivate changeState:]: unrecognized selector sent to instance 0x95c17d0'
需要在build settings里的other linker flags添加-ObjC標志
錯誤3. 無法正確顯示廣告,log打出“Cannot determine request type. Is your ad unit id correct?”
需改代碼:
self.adBanner.adUnitID = kSampleAdUnitID;
變量kSampleAdUnitID的定義指需改為你的Admob發布者ID。