iOS 老项目添加 Cocoapods 填坑过程

2017-05-08  本文已影响0人  Sparkle_S

一、老项目的描述:
首先来描述一下我所谓的老项目,项目创建于12年,至今的五年时间中未重构过,目前项目的内存管理机制是使用的MRC ┭┮﹏┭┮,对于第三方依赖库是纯手工管理 ~ o(>_<)o ~。
二、所填坑的解决办法:.
Cocoapods 的安装和使用我就不多说了,网上一抓一大把。
在多次填坑之后我终于将 Cocoapods 成功的添加到项目中,下面说说我填过的这些坑们:

[!] The `MaiChang [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-MaiChang/Pods-MaiChang.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `MaiChang [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-MaiChang/Pods-MaiChang.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) 替换掉。可参考下图


设置OTHER_LDFLAGS.png
设置ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES.png
ld: library not found for -lSDAutoLayout

原因我忘记了(╯﹏╰)。解决办法可见下图:


Edit Scheme.png
dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /private/var/containers/Bundle/Application/B221905D-47DC-4760-B3FE-81452B9111EB/MaiChang.app/Frameworks/SocketIO.framework/SocketIO
  Reason: image not found
Message from debugger: Terminated due to signal 6

产生此警告的原因是因为,项目没有正确的嵌入 swift 标准库。其实根本上因为对 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES 的设置有误引起的问题。解决办法:检查 Target 中该选项的值是否为Yes。(/(ㄒoㄒ)/~~这样就造成更新 Cocoapods 时出现警告,具体见第一枚坑。所以在使用 Cocoapods 管理依赖库的时候,不建议手动导入依赖库)

Apple Mach-O Linker (ld) Error Group
error: Invalid bitcode signature
clang: error: linker command failed with exit code 1 (use -v to see invocation)

原因不知道。解决办法见下图:


设置 Build Active Architecture Only.png
Use of '@import' when modules are disabled

Apple 在 LLVM5.0 引入了一个新的编译符号 @import 。较老的代码,需要在Build Settings中将Enable Modules(C and Objective-C)打开。如下图:


设置 Enable Modules.png

期待你的评论建议O(∩_∩)O~

上一篇 下一篇

猜你喜欢

热点阅读