一.創(chuàng)建開源的Public倉庫
這個有點簡單,就不記錄
二.創(chuàng)建podspec描述文件
語法: pod spec create 工程名
s.name 倉庫名字
s.license 文件類型
s.requires_arc 是否支持ARC
s.version 當前版本號
s.platform 支持的平臺
s.framework 導(dǎo)入依賴的框架庫
s.summary 倉庫功能的描述
s.author 作者信息
s.source_files 源文件的路徑(相對podspec文件而定)
s.resourcs 資源文件,不需參與編譯的
s.homepage 主頁地址
s.source 具體路徑
s.public_header_files 預(yù)編譯頭文件路徑
我的podspec:
Pod::Spec.new do |s|
s.name = 'YYBannerdemo'
s.summary = 'A banner of illusion.'
s.version = '1.0'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "yuanshuang" => "1006228982@qq.com" }
s.social_media_url = 'http://www.itdecent.cn/p/974342c2be31'
s.homepage = 'https://github.com/sdupidBoby/YYBannerdemo'
s.ios.deployment_target = '8.0'
s.platform = :ios, "8.0" #平臺及支持的最低版本
s.source = { :git => 'https://github.com/sdupidBoby/YYBannerdemo.git', :tag => s.version.to_s }
s.requires_arc = true
s.source_files = 'YYBannerView/*.{h,m}'
s.frameworks = 'UIKit'
end
三. 為源代碼添加對應(yīng)的Tag
- 在GitHub上面的源代碼需要打上版本號標簽,這樣Cocoapods管理器才能更準確地找到你的repo
- 通過Iterm命令push源代碼的tag值
git tag '1.0' // 生成版本號
git push --tags //提交標簽
號外:
git push origin --delete 1.0//刪除遠程tag 1.0
git tag -d 1.0刪除本地tag 1.0

3. pod spec lint --allow-warnings //檢查podspec是否可用哦

pod spec lint錯誤記錄:
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=can%27t+modify+frozen+String&type=Issues
If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new
Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
Don't forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods...
- Error: can't modify frozen String
https://github.com/CocoaPods/CocoaPods/issues/1444 [closed] [8 comments]
a day ago
- 上面的錯誤,解決辦法:
- 安裝最新版本
cocoapods sudo gem install -n /usr/local/bin cocoapods --pre
- 安裝最新版本
** BUILD FAILED **
The following build commands failed:
CompileC /Users/admin/Library/Developer/Xcode/DerivedData/App-fdruiackchwmffadzdsjvjiktwas/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/YYBannerdemo.build/Objects-normal/i386/YYBannerContentView.o YYBannerdemo/YYBannerView/YYBannerContentView.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC /Users/admin/Library/Developer/Xcode/DerivedData/App-fdruiackchwmffadzdsjvjiktwas/Build/Intermediates.noindex/Pods.build/Release-iphonesimulator/YYBannerdemo.build/Objects-normal/i386/YYRollBarView.o YYBannerdemo/YYBannerView/YYRollBarView.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)
Testing with `xcodebuild`.
-> YYBannerdemo (1.0)
- ERROR | [iOS] file patterns: The `vendored_frameworks` pattern did not match any file.
- WARN | [iOS] license: Unable to find a license file
- ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
- NOTE | [iOS] xcodebuild: YYBannerdemo/YYBannerView/YYBannerView.m:8:9: fatal error: 'Masonry.h' file not found
- NOTE | [iOS] xcodebuild: YYBannerdemo/YYBannerView/YYBannerContentView.m:10:9: fatal error: 'UIImageView+WebCache.h' file not found
- NOTE | [iOS] xcodebuild: YYBannerdemo/YYBannerView/YYRollBarView.m:8:9: fatal error: 'Masonry.h' file not found
Analyzed 1 podspec.
[!] The spec did not pass validation, due to 2 errors and 1 warning.
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0.beta.2/lib/cocoapods/command/spec/lint.rb:94:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0.beta.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.6.0.beta.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
- 上面的錯誤,解決辦法:
- 添加依賴 :
- s.dependency 'SDWebImage'
- s.dependency 'Masonry'
4. 沒有注冊Trunk的話,注冊一個賬號
pod trunk me-
pod trunk register 1006228982@qq.com 'sdupidBoby' --verbose- 注冊Trunk賬號,回車之后去打開郵箱的鏈接(需要copy,不能直接點擊)即可完成
pod trunk push YYBannerdemo.podspec --allow-warnings

5. 更新本地pod依賴庫
pod setuppod search YYBannerdemo
完成了,掘金參考鏈接
在podfile中添加測試
pod 'YYBannerdemo'