建立自己的pod (GitHub&私有)
阿新 • • 發佈:2018-12-16
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 [email protected].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