美文网首页
cocoapods 导入报警target overrides t

cocoapods 导入报警target overrides t

作者: LanWor | 来源:发表于2017-04-21 11:25 被阅读94次

    使用cocoapods导入第三方库的时候会出现这种错误:

    library not found for -lPods

    导致这个错误可能有两个原因,这两个原因在编译过程中都是有蛛丝马迹可循的。

    在 pod install时,就会有告警信息提示:

    Pod installation complete! There is 1 dependency from the Podfile and 6 total pods installed.

    [!] The `TotalAPP [Debug]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-TotalAPP/Pods-TotalAPP.debug.xcconfig'. This can lead to problems with the CocoaPods installation

    - Use the `$(inherited)` flag, or

    - Remove the build settings from the target.

    [!] The `TotalAPP [Release]` target overrides the `OTHER_LDFLAGS` build setting defined in `Pods/Target Support Files/Pods-TotalAPP/Pods-TotalAPP.release.xcconfig'. This can lead to problems with the CocoaPods installation

    - Use the `$(inherited)` flag, or

    - Remove the build settings from the target.

    这种警告是不能忽视的,它带来的直接后果就是无法通过编译。

    而产生此警告的原因是项目 Target 中的一些设置,CocoaPods 也做了默认的设置,如果两个设置结果不一致,就会造成问题。

    很明确的告知:通过添加 `(inherited)` flag 可以解决该问题。

    根据调试确认,OTHER_LDFLAGS 指的是 other linker flags; OTHER_CFLAGS 指的是 other c flags;HEADER_SEARCH_PATHS 指的是 header search paths.

    我想要使用 CocoaPods 中的设置,分别在我的项目中定义`PODS_ROOT` 和 `Other Linker Flags`的地方,把他们的值用`$(inherited)`替换掉,进入终端,执行

    pod update

    警告没了,回到 Xcode,build通过。

    原因2:

    在编译时有如下的警告和错误:

    1.警告: Target 'Pods' of project 'Pods' was rejected as an implicit dependency for 'libPods.a' because its architectures 'arm64' didn't contain all required architectures 'armv7 arm64'

    2.错误: ld: library not found for -lpop

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

    这里不留神可能警告会被忽略(毕竟在一个老项目中有一些警告很正常),但这个警告才是问题的关键。

    pod里面的build选项里build active architecture only 在 debug情形下默认是 YES, 这里如果和你项目的该设置不匹配(笔者用来调试的项目这里设置就是NO)的话那么就会报告该错误。

    在pods里面的target中挨个修改其配置和原有的工程一致,然后clean编译,项目即可正常运行。

    相关文章

      网友评论

          本文标题:cocoapods 导入报警target overrides t

          本文链接:https://www.haomeiwen.com/subject/xzcdzttx.html