一.创建开源的Public仓库
这个有点简单,就不记录
二.创建podspec描述文件
语法: pod spec create 工程名
s.name 仓库名字
s.license 文件类型
s.requires_arc 是否支持ARC
s.version 当前版本号
s.platform 支持的平台
s.framework 导入依赖的框架库
s.summary 仓库功能的描述
s.author 作者信息
s.source_files 源文件的路径(相对podspec文件而定)
s.resourcs 资源文件,不需参与编译的
s.homepage 主页地址
s.source 具体路径
s.public_header_files 预编译头文件路径
我的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 = 'https://www.jianshu.com/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
三. 为源代码添加对应的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 setup
pod search YYBannerdemo
完成了,掘金参考链接
在podfile中添加测试
pod 'YYBannerdemo'
网友评论