iOS组件化(一):创建本地私有库

1.创建Test项目,创建TestLib,添加Person类

image.png

2.git init

image.png

3.提交代码

image.png

4.创建项目的podspec文件

image.png

image.png

5.修改podspec文件,保存

s.name         = "TestLib"
s.version      = "0.0.1"
s.summary      = "TestLib"
s.description  = "TestLib测试"
s.homepage     = "http://EXAMPLE/TestLib"
s.license      = "MIT"
s.source       = { :git => "", :tag => "#{s.version}" }  #本地的git不用填

注意:s.summary的内容一定要比s.description的内容短
s.homepage本地私有库不需要改,如果是远程的话就需要修改

6.在Test文件夹下创建podfile文件

image.png
image.png

7.修改podfile文件,再pod install

image.png

8.出错:

image.png
出错原因:上面的写法会在远程仓库中查找,我们的TestLib是本地的,当然查找不到
image.png

9.修改podfile文件,使它在本地查找

image.png

10.重新pod install,安装成功

image.png

打开项目,可以在Development Pods(本地库存放位置)中看到TestLib,在Test工程里#import <Person.h>就可以使用了
image.png

11.如果Person类有改动的话,需要重新提交代码,cd 到TestLib目录下提交

image.png

12.如果新建文件:在Classes中新建两个文件

image.png

cd 到Test目录下,pod install
image.png
image.png

猜你喜欢

转载自www.cnblogs.com/WinJayQ/p/9269784.html