1.创建远程spec repo
spec repo 是pod存放.podspec描述文件的库,一般所有公开的pods都保存这个库里面
在GitHub上创建spec repo,公开or私有都可以
image.png
添加到本地~/.cocoapods/repos目录下
pod repo add gbl-repo https://github.com/gebulin-boot/gbl-repo.git
完成以后会在~/.cocoapods/repos/出现gbl-repo目录
. .DS_Store gbl-repo
2创建私有git仓库
此处创建的私有git仓库是保存我们代码的仓库,以在GitHub上创建私有库为例:
image.png3.在本地创建pod库
pod lib create publicTool
中间会有提示按照要求选择,平台,语言,demo等,
修改.podspec
以上详细过程可参考cocopods公有库的创建
代码测试通过后,提交代码到git本地仓库
git add .
git commit -s -m '初始化'
推送到远程git私有仓库
git remote add origin git@github.com:gebulin-boot/Public-specs.git
git push origin master
打上tag
git tag
git tag '0.1.0'
git push --tags
检查podspec文件
pod spec lint
验证通过之后,在当前.podspec目录下,推送到一开始创建的位于 .cocopods/repos/gbl-repo仓库
pod repo push gbl-repo privateTool.podspec
可能会报错:
Validating spec
-> privateTool (0.1.0)
- WARN | summary: The summary is not meaningful.
- WARN | url: The URL (https://github.com/gebulin-boot/private-repo) is not reachable.
- NOTE | xcodebuild: note: Using new build system
- NOTE | xcodebuild: note: Building targets in parallel
- NOTE | xcodebuild: note: Using codesigning identity override: -
- NOTE | xcodebuild: note: Build preparation complete
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Analyzing workspace
- NOTE | [iOS] xcodebuild: note: Constructing build description
- NOTE | [iOS] xcodebuild: warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
[!] The `privateTool.podspec` specification does not validate.
如果是警告引起的报错,忽略警告再次推送
pod repo push gbl-repo privateTool.podspec --allow-warnings
出现以下提示代表成功:
- [Add] privateTool (0.1.0)
Pushing the `gbl-repo' repo
同时在.cocopods/repos/gbl-repo目录下能看到刚才的.podspec文件
image.png通过pod搜索是可以搜到的
pod search privateTool
搜索结果如下:
-> PrivateTool (0.1.0)
A short description of privateTool.
pod 'PrivateTool', '~> 0.1.0'
- Homepage: https://github.com/gebulin-boot/private-repo
- Source: https://github.com/gebulin-boot/private-repo.git
- Versions: 0.1.0 [gbl-repo repo]
-> privateTool (0.1.0)
A short description of privateTool.
pod 'privateTool', '~> 0.1.0'
- Homepage: https://github.com/gebulin-boot/private-repo
- Source: https://github.com/gebulin-boot/private-repo.git
- Versions: 0.1.0 [gbl-repo repo]
到此,私有cocopods创建完成
网友评论