pod subspec 子模块
2018-03-09 本文已影响919人
Theshy
pod私有库创建详细教程
pod
私有库搭建完成后,给私有库创建子模块如图的形式

一、修改文件夹结构


二、上传改动到远程代码仓库
$ git add .
$ git commit -m "文件夹结构调整"
$ git push -u origin master
//tag 值增加
$ git tag 0.1.1
//推送tag到服务器上
$ git push --tags
三、修改.podspec

终端输入pod sepc lint
校验 spec

四、提交spec
pod repo push TestLib TestLib.podspec --sources=http://git.weiyankeji.cn/yuehuig/TestSpec.git
五、项目中使用pod库
三种用法
-
pod 'TestLib'
引入pod
库中所有模块 -
pod 'TestLib/GTimer'
只引入GTimer
模块 pod 'TestLib', :subspecs => ['Extension', 'GTimer']

安装即可
六、子模块中依赖三方库
添加dependency

执行pod spec lint
会报警告

[!] The spec did not pass validation, due to 1 warning (but you can use `--allow-warnings` to ignore it).
命令加参数--allow-warnings

然后推送spec
到远程、指令也需加上--allow-warnings
此时仍报错
ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for

因为依赖的三方库是官方pod
库中的,添加上源

七、子模块依赖静态库

执行检测pod spec lint --allow-warnings
报错
- ERROR | [iOS] unknown: Encountered an unknown error (The 'Pods-App' target has transitive dependencies that include static binaries:

这个错误是因为依赖库s.dependency
包含了.a
静态库造成的。虽然这并不影响Pod
的使用,但是验证是无法通过的。可以通过 --use-libraries
来让验证通过。
pod install
报错
[!] The 'Pods-OCTestLib_Example' target has transitive dependencies that include static binaries: (/Users/yuehuig/OCTestLib/Example/Pods/GTSDK/GTSDK.framework)
尝试在podspec中加入
s.static_framework = true
不行的话,换第二种方法 在podfile
中加入
pre_install do |installer|
# workaround for #3289
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end