ios 项目添加AdMob 错误记录

依照官方教程添加文件及其 frameWork后 发现运行报错 错误如下

Undefined symbols for architecture i386:

  "_OBJC_CLASS_$_ASIdentifierManager", referenced from:

      objc-class-ref in libGoogleAdMobAds.a(GADIdentifierUtilities.o)

ld: symbol(s) not found for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

Undefined symbols for architecture i386:

"_OBJC_CLASS_$_SKStoreProductViewController", referenced from:

  objc-class-ref in RevMobAds(RevMobStoreController.o)

"_SKStoreProductParameterITunesItemIdentifier", referenced from:

  -[RevMobStoreController openStoreWithITunesItemId:] in RevMobAds(RevMobStoreController.o)

ld: symbol(s) not found for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)

最终通过添加 frameWork搞定  添加了 StoreKit.framework    AdSupport.framework  CoreData.framework .

运行继续报错

ld: duplicate symbol _OBJC_CLASS_$_AppDelegate in /Users/AbhilashReddy/Library/Developer/Xcode/DerivedData/santabantaa-bykvybsbvqshqshfqxdlsxiqhehc/Build/Intermediates/santabantaa.build/Debug-iphonesimulator/santabantaa.build/Objects-normal/i386/AppDelegate-C7A14BE43C5E8C81.o and /Users/AbhilashReddy/Library/Developer/Xcode/DerivedData/santabantaa-bykvybsbvqshqshfqxdlsxiqhehc/Build/Intermediates/santabantaa.build/Debug-iphonesimulator/santabantaa.build/Objects-normal/i386/AppDelegate-A37C3709371E4892.o for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)

 

原来很是2的把demo也给弄进来了,删除demo的那个文件夹Add-ons 就好了

再次报错 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GADObjectPrivate changeState:]: unrecognized selector sent to instance 0x95c17d0'

解决方案 add -ObjC to the Other Linker Flags of your application target's build setting。

加了个广告 他妹的把所有能碰到的问题都碰到了 真是技术不纯熟害死人啊。~~~

PS:要弄个全屏的Admob 看了下SDK 似乎没有 就自己动手写  

[[GADBannerView alloc] initWithFrame:self.view.bounds];  结果报错 errors = "Ad size will not fit on screen"  

但是改为 [[GADBannerView alloc] initWithFrame:CGRectMake(0,0,320,480)];  就可以。 但是同时写了下半屏的CGRect,发现半屏的 frame 显示的不完全,左右被压缩得很厉害,造成了只显示了一个icon和一个按钮。不知道怎么解决。

 

 

 

原文地址:https://www.cnblogs.com/superhappy/p/2817131.html