大體步驟可以總結(jié)為以下幾行命令
pod spec create JHDynamicFont
git tag -m"pod spec" "0.0.1"
git push origin --tags
pod trunk register 807880748@qq.com 'jinghao' --description='ios developer' --verbose
pod lib lint --allow-warnings
pod trunk push JHDynamicFont.podspec --allow-warnings
- podspec文件設(shè)置如下
Pod::Spec.new do |s|
s.name = "JHDynamicFont"
s.version = "0.0.1"
s.summary = "通過為UIFontDescriptor添加category方法實(shí)現(xiàn)動(dòng)態(tài)改變指定控件(如UILabel UIButtonLabel等)的字體大小及刻。"
s.description = <<-DESC
通過為UIFontDescriptor添加category方法實(shí)現(xiàn)動(dòng)態(tài)改變指定控件(如UILabel UIButtonLabel等)的字體大小!!!
DESC
s.homepage = "https://github.com/Shenjinghao/JHDynamicFont"
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
s.license = "MIT"
# s.license = { :type => "MIT", :file => "FILE_LICENSE" }
s.author = { "shenjinghao" => "807880748@qq.com" }
s.source = { :git => "https://github.com/Shenjinghao/JHDynamicFont.git", :tag => "#{s.version}" }
s.source_files = "Classes", "JHDynamicFont/Classes/**/*.{h,m}"
s.exclude_files = "Classes/Exclude"
s.requires_arc = true
s.platform = :ios
end
具體步驟可以參考相關(guān)文章鏈接
下面主要介紹下集成過程出現(xiàn)的問題及解決方法渡处,以我自己提交的一個(gè)項(xiàng)目(JHDynamicFont施无,通過UIFontDescriptor可以動(dòng)態(tài)修改字體大小,項(xiàng)目地址)為例:
- NOTE | [OSX] xcodebuild: /Users/shenjinghao/Desktop/Module/MyModule/JHDynamicFont/JHDynamicFont/JHDynamicFont/Classes/JHSliderView.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
- 出現(xiàn)上面類似的錯(cuò)誤是因?yàn)樵趐odspec文件中沒有加
s.platform = :ios
- ERROR | file patterns: The
source_files
pattern did not match any file.
- 出現(xiàn)上面的錯(cuò)誤需要把podspec文件中的source_files改成類似下面這種
s.source_files = "Classes", "JHDynamicFont/Classes/**/*.{h,m}"
-> JHDynamicFont (0.0.1)
- ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/Shenjinghao/JHDynamicFont.git /var/folders/lc/zl333w0s6t12qjdfl0_brmdh0000gn/T/d20170315-37512-16fmh2q --template= --single-branch --depth 1 --branch 0.0.1
Cloning into '/var/folders/lc/zl333w0s6t12qjdfl0_brmdh0000gn/T/d20170315-37512-16fmh2q'...
warning: Could not find remote branch 0.0.1 to clone.
fatal: Remote branch 0.0.1 not found in upstream origin
- 出現(xiàn)上面錯(cuò)誤的原因是沒有為項(xiàng)目打上tag丹泉,或者打上tag沒有推到遠(yuǎn)程倉庫情萤,在teminal輸入下面命令
git tag -m"pod spec" "0.0.1"
git push origin --tags
[!] JHDynamicFont did not pass validation, due to 1 error.
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a.swift-version
file to set the version for your Pod. For example to use Swift 2.3, run:
echo "2.3" > .swift-version
.
You can use the--no-clean
option to inspect any issue.
- 出現(xiàn)上面問題在終端輸入
echo 3.0 > .swift-version
成功提示
JHDynamicFont passed validation.
- 出現(xiàn)上面提示說明podspec已經(jīng)驗(yàn)證成功,可以提交CocoaPods trunk了
--------------------------------------------------------------------------------
?? Congrats
?? JHDynamicFont (0.0.1) successfully published
?? February 10th, 04:05
?? https://cocoapods.org/pods/JHDynamicFont
?? Tell your friends!
- 出現(xiàn)上面提示說明提交CocoaPods trunk成功摹恨。
剛提交后項(xiàng)目用pod search命令會(huì)搜不到筋岛,因?yàn)楸镜氐乃饕龥]有更新,使用下面命令刪除索引文件
rm ~/Library/Caches/CocoaPods/search_index.json
- 最后pod search 命令搜到自己的項(xiàng)目晒哄,大功告成
-> JHDynamicFont (0.0.1)
通過為UIFontDescriptor添加category方法實(shí)現(xiàn)動(dòng)態(tài)改變指定控件(如UILabel UIButtonLabel等)的字體大小睁宰。
pod 'JHDynamicFont', '~> 0.0.1'
- Homepage: https://github.com/Shenjinghao/JHDynamicFont.git
- Source: https://github.com/Shenjinghao/JHDynamicFont.git
- Versions: 0.0.1 [master repo]
(END)
2017年03月22日17:46:44更新
- 出現(xiàn)上面的錯(cuò)誤提示可以更新cocoapods,命令如下
sudo gem install cocoapods
//或者
sudo gem install cocoapods --pre