一.创建远程索引库
- 在github上创建仓库
- 在终端上将刚才创建的远程仓库地址与本地进行关联
-
bogon:~ junyangyang$ pod repo add JYYTestSpec https://github.com/junyangyang/JYYTestSpec.git Cloning spec repo `JYYTestSpec` from `https://github.com/junyangyang/JYYTestSpec.git`
二.创建私有仓库
pod lib create JYYTest
会进行以下一系列的设置
平台,语言,是否生成demo,测试framework,设置完成之后,会自动打开一个xcode测试项目
What platform do you want to use?? [ iOS / macOS ]
> iOS
What language do you want to use?? [ Swift / ObjC ]
> Swift
Would you like to include a demo application with your library? [ Yes / No ]
> Yes
Which testing frameworks will you use? [ Quick / None ]
> None
Would you like to do view based testing? [ Yes / No ]
> Yes
Running pod install on your new library.
- 自动生成的测试demo
- 随便创建一个文件JYYToolTest.swift,将该文件添加到JYYTest->Classes文件夹下,并删掉replaceMe.swift
继续在github上创建仓库 JYYTest
创建成功后,配置测试demo文件下的JYYTest.podspec,可以以文本编辑打开,修改相关配置,并保存退出
讲本地代码提交到远程仓库JYYTest
bogon:JYYTest junyangyang$ git remote add origin https://github.com/junyangyang/JYYTest.git
bogon:JYYTest junyangyang$ git push -u origin master
bogon:JYYTest junyangyang$ git add .
bogon:JYYTest junyangyang$ git commit -m 'first blood'
bogon:JYYTest junyangyang$ git push -u origin master
bogon:JYYTest junyangyang$ git tag '0.0.1' //该tag值需要与JYYTest.podSpec里的tag保持一致
bogon:JYYTest junyangyang$ git push --tag
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/junyangyang/JYYTest.git
* [new tag] 0.0.1 -> 0.0.1
- 从本地验证
pod
能否通过验证
bogon:JYYTest junyangyang$ pod lib lint --use-libraries --allow-warnings
-> JYYTest (0.0.1)
- WARN | summary: The summary is not meaningful.
- WARN | [iOS] swift: The validator used Swift `4.0` by default because no Swift version was specified. To specify a Swift version during validation, add the `swift_versions` attribute in your podspec. Note that usage of a `.swift-version` file is now deprecated.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- 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')
- NOTE | [iOS] xcodebuild: note: Execution policy exception registration failed and was skipped: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" (in target 'App' from project 'App')
JYYTest passed validation.
- 从本地和远程验证的
pod
能否通过验证
bogon:JYYTest junyangyang$ pod spec lint --use-libraries --allow-warnings
-> JYYTest (0.0.1)
- WARN | summary: The summary is not meaningful.
- WARN | [iOS] swift: The validator used Swift `4.0` by default because no Swift version was specified. To specify a Swift version during validation, add the `swift_versions` attribute in your podspec. Note that usage of a `.swift-version` file is now deprecated.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- 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')
- NOTE | [iOS] xcodebuild: note: Execution policy exception registration failed and was skipped: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" (in target 'App' from project 'App')
Analyzed 1 podspec.
JYYTest.podspec passed validation.
--verbose
:有些非语法错误是不会给出错误原因的,这个时候可以使用--verbose
来查看详细的验证过程来帮助定位错误。--use-libraries
:表示使用静态库或者是framework,这里主要是解决当我们依赖一些framework库后校验提示找不到库的时候用到。--allow-warnings
:表示允许警告。
- 将
spec
文件提交到本地的私有仓库,然后再push
到远程仓库
bogon:JYYTest junyangyang$ pod repo push JYYTestSpec JYYTest.podspec --use-libraries --allow-warnings
错误信息
解决办法,可以在远程索引库JYYTestSpec,随便创建一个文件例如readme即可
创建完成后,我们继续
bogon:JYYTest junyangyang$ pod repo push JYYTestSpec JYYTest.podspec --use-libraries --allow-warnings
bogon:JYYTest junyangyang$ pod repo push JYYTestSpec JYYTest.podspec --use-libraries --allow-warnings
Validating spec
-> JYYTest (0.0.1)
- WARN | summary: The summary is not meaningful.
- WARN | [iOS] swift: The validator used Swift `4.0` by default because no Swift version was specified. To specify a Swift version during validation, add the `swift_versions` attribute in your podspec. Note that usage of a `.swift-version` file is now deprecated.
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- 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')
- NOTE | [iOS] xcodebuild: note: Execution policy exception registration failed and was skipped: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted" (in target 'App' from project 'App')
Updating the `JYYTestSpec' repo
Adding the spec to the `JYYTestSpec' repo
- [Add] JYYTest (0.0.1)
Pushing the `JYYTestSpec' repo
bogon:JYYTest junyangyang$
此时可以看创建的远程索引库有了变化
pod search JYYTest
-> JYYTest (0.0.1)
A short description of JYYTest.
pod 'JYYTest', '~> 0.0.1'
- Homepage: https://github.com/junyangyang/JYYTest
- Source: https://github.com/junyangyang/JYYTest.git
- Versions: 0.0.1 [JYYTestSpec repo]
- 现在我们可以在项目中引用我们的私有库
pod 'JYYTool', :git => "https://github.com/junyangyang/JYYTest.git"
如果想朋友也用到自己写的仓库
首先在终端输入,注册trunk,输入邮箱,我们邮箱可以收到一封邮件(可能在垃圾邮箱里),点一下链接即可
pod trunk register 571172886@qq.com 'mxObject-c' --description='regist trunk'
pod trunk push /Users/junyangyang/JYYTest/JYYTest.podspec --allow-warnings
成功之后,我们便可直接输入tag版本号,即可
pod 'JYYTest', '~> 0.0.1'
更新本地pod库才可以 pod setup
更新组件
修改Classes文件下对应的库文件
修改JYYTest.podSpec的版本号
代码更新
git add .
git commit -m 'second'
git pull
git push origin master
版本更新 这一步非常重要,为更新索引库做准备
git tag -a '0.0.1' -m 'second'
git push --tags
更新索引库
- 验证远程lib
pod lib lint --use-libraries --allow-warnings
- 验证远程spec
pod spec lint --use-libraries --allow-warnings
- 更新索引库 结束 。
pod repo push JYYTestSpec JYYTest.podspec --use-libraries --allow-warnings
--use-libraries
:表示使用静态库或者是framework
--allow-warnings
:表示允许警告。
Updating the `JYYTestSpec' repo
Adding the spec to the `JYYTestSpec' repo
- [Update] JYYTest (0.0.3)
Pushing the `JYYTestSpec' repo
bogon:JYYTest junyangyang$