将ios核心框架添加到podfile

时间:2018-02-03 13:01:08

标签: ios admob cocoapods podfile linker-flags

我在我的Podfile中添加了一个pod,并在构建时遇到编译器错误:

Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_CLLocation", referenced from:
     objc-class-ref in MoPubAdapter(GADMAdapterMoPub.o)
  ld: symbol(s) not found for architecture arm64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

然后我转到Build Settings > Target > Debug > Other Linker Files并手动添加了-framework"CoreLocation"

enter image description here

编译器不再抱怨了。我认为他们被遗忘作为pod的先决条件。

现在我不喜欢手动更改此值的事实。如果Cocoapods再次覆盖这个值,我可能会忘记这样做。有没有办法让我将CoreLocation框架添加到Podfile中,以便Cocoapods负责包含它?

由于

2 个答案:

答案 0 :(得分:0)

恐怕无法做到这一点。 Apple并未在Cocoapods上提供对其核心框架的依赖。作为测试,您可以在Cocoapods上搜索任何核心库。你不会发现那个。作为简短测试,如果您尝试在 Podfile 中设置pod CoreLocation,则会出现以下结果。

enter image description here

可悲的是,手动修复此问题是唯一的解决方法。

答案 1 :(得分:0)

您可以将Podfile中的依赖项添加到仅向CoreLocation添加依赖项的最小CocoaPod。有关创建podspec的信息,请参见here;有关从本地路径引用podspec的信息,请参见here

更好的解决方案是更新违规广告连播的podspec,将CoreLocation添加为framework