IOS在接入 AdMob廣告的時候根據https://developers.google.com/admob/ios/quick-start,的步驟進行,通過pod倒入sdk之後
通過下列方式初始化,注意不能按官方文檔中的引入頭文件,要通過下面
#import <GoogleMobileAds/GoogleMobileAds.h>
#import <GoogleMobileAds/GoogleMobileAds.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[GADMobileAds sharedInstance] startWithCompletionHandler:nil];
return YES;
}
@end
然後運行後回報錯:
Undefined symbols for architecture x86_64:"_OBJC_CLASS_$_GADMobileAds", referenced from: objc-class-ref in AppController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
#import <GoogleMobileAds/GoogleMobileAds.h>
解決方案:
如果用CocoaPods導入的庫,Build Setting->Linking->Other Linker Flags,添加$(inherited)