請先安裝CocoaPods,步驟可以自行百度,這里略過.
廢話不多說,直接上步驟
1. 在gitee創(chuàng)建一個空項目作為私有的遠(yuǎn)程索引庫(HMXRepo)
2. 將私有的遠(yuǎn)程索引庫Copy到本地
pod repo add FERSpecs https://gitee.com/Bu_Jie/HMXRepo.git
執(zhí)行完成之后缩膝,可以在~/.cocoapods/repos
目錄中看到自己的遠(yuǎn)程索引庫。
3. 創(chuàng)建一個空項目作為私有庫(HMXPodTest)
4. 將創(chuàng)建的HMXPodTest克隆到想要放置私有庫的位置
先cd
到將要存放私有庫的目錄
cd /Users/bujie/HMX/ModulizationDemo
然后將創(chuàng)建的HMXPodTest克隆到該目錄
git clone https://gitee.com/Bu_Jie/HMXPodTest.git
5. 為HMXPodTest添加代碼丽涩、podspec、LICENSE
- 拷貝準(zhǔn)備好的HMXPodTest.podspec到HMXPodTest目錄中(你可以從這里拿)
- 拷貝準(zhǔn)備好的LICENSE到HMXPodTest目錄中你可以從這里拿)
- 在HMXPodTest中創(chuàng)建一個新的文件夾裁蚁,文件夾的命名為HMXPodTest
- 將代碼以及資源拷貝到新創(chuàng)建的文件夾中
最后文件目錄的結(jié)構(gòu)如下:
6. 修改HMXPodTest.podspec文件
Pod::Spec.new do |s|
s.name = 'HMXPodTest'
s.version = '0.1.0'
s.summary = 'Podtest'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://gitee.com/Bu_Jie'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { '不介' => 'yi.huang@casstime.com' }
s.source = { :git => 'https://gitee.com/Bu_Jie/HMXPodTest.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
s.ios.deployment_target = '8.0'
s.source_files = 'HMXPodTest/Classes/**/*'
# s.resource_bundles = {
# 'HMXPodTest' => ['HMXPodTest/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
end
-
s.name
修改為私有庫的名稱矢渊,這里是HMXPodTest
-
s.summary
可以修改為私有庫的相關(guān)描述 -
s.homepage
建議修改為你的主頁 -
s.author
修改為你自己的信息 -
s.source
修改為你創(chuàng)建的私有庫的地址 -
s.source_files
如果是按照之前描述的目錄存儲的文件,這里不用修改
7. 修改LICENSE
Copyright (c) 2019 不介 <yi.huang@casstime.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-
Copyright
修改為自己的信息
8. 驗證本地庫
pod lib lint --allow-warnings --verbose
如果有Error
就需要修改枉证,--allow-warnings
可以忽略警告
9. 將本地代碼推到遠(yuǎn)程倉庫
如果本地庫驗證通過昆淡,就可以把代碼推到遠(yuǎn)程倉庫
git remote add origin https://gitee.com/Bu_Jie/HMXPodTest.git
git add .
git commit -m "Initial Commit"
git push -u origin master
10. 為遠(yuǎn)程倉庫打Tags
打Tags的操作必須是在將代碼推送到遠(yuǎn)程倉庫之后,而且這個tag必須與HMXPodTest.podspec中的s.version
一致刽严。
git tag -m "Initail" 0.1.0
git push --tags
11. 驗證遠(yuǎn)程庫
pod spec lint --allow-warnings --verbose
這個命令與pod lib lint
類似,區(qū)別是這個命令驗證的是遠(yuǎn)程庫
12. 注冊trunk
pod trunk register 郵箱 '用戶名' —descripttion='描述'
- 郵箱:是gitee上登錄的郵箱
- 用戶名:是gitee上的用戶名
執(zhí)行命令后避凝,郵箱中會接收到一封郵件舞萄,點擊郵件中的鏈接完成注冊
13. 將私有庫推送到CocoaPods上
pod trunk push HMXPodTest.podspec
這條命令可能會等一段時間,請耐心
14. 查看個人信息
pod trunk me
- Name:
- Email:
- Since: May 4th, 00:03
- Pods:
- HMXPodTest
- Sessions:
如果將私有庫推送到CocoaPods上成功管削,Pods
中就會有你的私有庫的名稱
15. 搜索私有庫
pod search HMXPodTest