首页 Pod 私有库踩坑记录
文章
取消

Pod 私有库踩坑记录

1. 引入第三方静态库 (Framework)

比如 frameworks 放在 WTBAuth/Vender 下面的某个文件夹里面. 在 podspec 中这么写:

1
s.vendored_frameworks = 'WTBAuth/Vender/*/*.framework'

2. 依赖系统库

例如 libstd++.tbd 省略 lib.tbd 后缀, 可以这么写:

1
s.libraries = 'stdc++'

3. 依赖自己的私有库

如果个人私有库没有在 Cocoapods 发布, 直接 s.dependency 'DKNetwork', 在 pod install 时候肯定会报错. 解决办法: 在 Podfile 里面也加入私有的 pod 相关配置:

1
pod 'DKNetwork', :git => 'https://host.com/username/DKNetwork.git'

并且同时在 podspec 中添加依赖:

1
s.dependency 'DKNetwork'

即可解决.

[!] The '' target has transitive dependencies that include static binaries: ......

4. 依赖中包含静态库

比如需要用友盟分享(包含几个framework), 并且 Podfile 里面有 use_framework!, 会报错: target has transitive dependencies that include static binaries 简单点的解决办法: 自己封装一下, 搞成一个 framework, 使用 1 中的办法引入进去.

5. 工程的配置

配置 Other Linker Flags :

1
s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => ['-ObjC' , '-lstdc++']  , 'ENABLE_BITCODE' => 'NO'}

配置 bitcode :

1
2
3
4
// 配置当前库的 bitcode
s.pod_target_xcconfig  = { 'ENABLE_BITCODE' => 'NO' }
// 配置宿主工程的 bitcode
s.user_target_xcconfig = { 'ENABLE_BITCODE' => 'NO' }
本文由作者按照 CC BY 4.0 进行授权