iOS 中建立私有库
步骤:
1. 新建项目名称 PodTestDemo
在桌面创建文件夹PodTest
在终端分别输入以下命令:
$cd /Users/admin/Desktop/PodTest
$pod lib create PodTestDemo

2. 然后会有一系列的配置问题回答
第一个问题是问你选择的平台是iOS还是macOS,这里选择iOS
第二个问题是问你选择Swift还是Objc构建项目, 此项目选的是ObjC
第三个问题问你是否需要创建一个Demo项目,此项目选的是Yes
第四个问题让你是否选择一个测试框架,此项目选 None
第五个问题是否基于View测试,选Yes
第六个问题是询问 类的前缀,设为YY


3. 在终端依次输入$pwd, $cd PodTestDemo/Example, $ls
查看Example的文件


4.打开Example文件下的 xcworkspace文件下的podspec文件

添加需要的库

终端输入:$pod install

即在项目中导入了相关的库

5.查看创建的项目是否有效
终端输入:$pod lib lint --allow-warnings
出现下图 即项目创建成功

6. 在gitHub上创建PodTestDemo库

7. 把本地创建好的PodTestDemo推送到gitHub上
方法:pwd在当前目录下,然后执行:
$git remote add origin https://github.com/xxxxx/PodCeshiDemo.git(刚创建的PodTestDemo的url)

如下图的命令:

注:如果提示出错信息:fatal: remote origin already exists.
则可以输入:$ git remote rm origin, 在重新输入$ git remote add origin https://github.com/xxxx/PodTestDemo.git
如下:github上就有了刚才推送的PodCeshiDemom项目

如果需要把PodCeshiDemo 放在另一个仓库下,则继续做如下操作:
8. 在gitHub上新建仓库PodTestSpec,


打开终端,执行如下操作:
打开cocoapods:$ open .cocoapods/
$pod repo add PodTestSpec https://github.com/xxxx/PodCeshiSpec.git (PodTestSpec的链接地址)

则发现repos文件下多了刚才创建的PodTestSpec文件

9. 把最开始创建的项目PodTestDemo 添加到SourceTee中管理
把PodTestDemo项目添加标签0.1.0,推送到远程origin

10. 在终端cd到PodTestDemo的路径
$cd /Users/admin/Desktop/PodTest/PodTestDemo
$pod repo push PodTestSpec PodTestDemo.podspec --allow-warnings --verbose
成功则出现下图的提示

执行成功后打开打开cocoapods(open .cocoapods/),则PodTestDemo出现在PodTestSpec仓库下

在gitHub上查看,PodTestDemo在PodTestSpec仓库下

