1. 终端
cd
到目标根目录下,输入:
pod lib create your_pod_name
What platform do you want to use?? [ iOS / macOS ]
What language do you want to use?? [ Swift / ObjC ]
Would you like to include a demo application with your library? [ Yes / No ]
Which testing frameworks will you use? [ Quick / None ]
Would you like to do view based testing? [ Yes / No ]
What is your class prefix? // Object-C
详细释义: using-pod-lib-create
ls
Example README.md TestPod.podspec
LICENSE TestPod _Pods.xcodeproj
cd Example
pod install
2. GitHub
在GitHub创建相应项目
生成的Podlib本身就是一个git,下面的操作要把本地的git和远程我们在GitHub上创建的相连,如下操作:
git remote add origin your_github_project_git_url
3. podspec
s.homepage = 'your_github_project_url'
s.author = { 'your_user_name' => 'your_email' }
s.source = { :git => 'your_github_project_git_url', :tag => s.version.to_s }
s.source_files = 'TestPod/Classes/**/*'
# 注意xib storyboard也属于 resource 文件
# s.resource = 'TestPod/Assets/TestPod.bundle'
# s.resource_bundles = {
# 'TestPod' => ['TestPod/Assets/*.png']
# }
# s.resource_bundles = {
# 'TestPod' => ['TestPod/Classes/*.xib']
# }
s.homepage
是POD的主页,s.source
是开源代码所在的git,这些都换成我们在gitlab上创建的git,s.dependency
是需要的依赖,s.frameworks
是需要的苹果官方的frameworks,s.description
,比较大段的描述,在TODO: Add long description of the pod here底下添加描述即可
检测podspec是否有误 pod lib lint
完成后需要在 Example 中执行pod update
4. 编写代码
- 注意 NSBundle
- Resource文件推荐打包成bundle文件使用
5. 发布
git tag 0.1.0
git push –tags
注册trunk
pod trunk register your_email 'your_user_name' --verbose
查看自己的注册信息
pod trunk me
若pod是由多人维护的,可以添加其他维护者
pod trunk add-owner your_pod_name other's_email
发布
pod trunk push --allow_warnings
更新版本
- .podspec
s.version = '0.1.1'
git tag 0.1.1
git push –tags
pod trunk push --allow-warnings
私有
在gitlab上创建一个空的仓库,例命名为EMZSpecs
,这个仓库是用来存放我们自己所有的私有库的spec文件
添加仓库地址到本地:
pod repo add EMZSpecs git@gitlab.com:your_user_name/EMZSpecs.git
查看源:
pod repo
EMZSpecs
- Type: git (master)
- URL: git@gitlab.com:libercata/EMZSpecs.git
- Path: /Users/waynn/.cocoapods/repos/EMZSpecs
master
- Type: git (master)
- URL: https://github.com/CocoaPods/Specs.git
- Path: /Users/waynn/.cocoapods/repos/master
提交仓库:
pod repo push EMZSpecs your_project.podspec --allow-warnings
查看是否成功
pod search your_project