一.创建开源的Public仓库
这个有点简单,就不记录
二.创建podspec描述文件
语法: pod spec create 工程名
s.name 仓库名字s.license 文件类型s.requires_arc 是否支持ARCs.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.0git 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=IssuesIf none exists, create a ticket, with the template displayed above, on:https://github.com/CocoaPods/CocoaPods/issues/newBe sure to first read the contributing guide for details on how to properly submit a ticket:https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.mdDon'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 foundAnalyzed 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 `'/usr/local/bin/pod:23:in `load'/usr/local/bin/pod:23:in ` '复制代码
- 上面的错误,解决办法:
- 添加依赖 :
- s.dependency 'SDWebImage'
- s.dependency 'Masonry'
4. 没有注册Trunk的话,注册一个账号
pod trunk me
pod trunk register 1006228982@qq.com 'sdupidBoby' --verbose
3. 注册Trunk账号,回车之后去打开邮箱的链接(需要copy,不能直接点击)即可完成pod trunk push YYBannerdemo.podspec --allow-warnings
5. 更新本地pod依赖库
pod setup
pod search YYBannerdemo
完成了,
在podfile中添加测试
pod 'YYBannerdemo'复制代码