1. 文件夹结构如下


2. 制作本地库
终端进入本地库的目录下
初始化git仓库,添加,并提交代码

终端输入
pod spec create PodTestLib

打开PodTestLib.podspec文件修改配置
修改 s.description = "PodTestLib 测试仓库"
修改s.license = "MIT"
注意,里面的s.source中,因为是本地库,所以后面git=>"这里面的地址删掉
"
保存 退出
至此 本地库制作完毕,在项目中导入本地库即可
3. 项目中导入本地库
终端进入项目本地库路径
输入指令
pod init
创建好podfile
, 打开podfile,修改配置文件
platform :ios, '8.0'
target 'PodTestProject' do
use_frameworks!
pod 'PodTestLib', :path=> '../LocalLib/PodTestLib'
#此处要找到本地库的podspec文件
end
保存 ,退出
终端输入 pod install
至此项目中所引用的本地库就已经完成。
一般还需要为我们的库添加一个测试工程。
比如在此 ,使用xcode 创建一个新的工程。用来以后测试本地库
将工程存放在PodTestLib目录下,取名为Example

终端进入Example目录下,输入pod init
然后打开podfile。修改配置,
# platform :ios, '8.0'
target 'Example' do
use_frameworks!
#指定path,找到podspec文件
pod 'PodTestLib',:path=>'../'
end
保存,退出,然后再终端输入 pod install
即可。
以上是手动设置Pod本地库。 下面将演示如何自动设置Pod本地库。
4 . 创建本地库带测试代码的简单方式
终端输入
pod lib create PodTestLib
等待下载完成。并根据需要填写相应的选项
完成之后,会自动创建好一个lib


替换完成之后,终端进入Example文件夹下

执行pod install , 即可自动更新文件

网友评论