1.进入项目目录,在终端上输入创建podspec文件的命令:
//CFStatusBarHUD是你框架的名称
pod spec create CFStatusBarHUD
2.编辑生成的podspec,在终端使用vim编辑CFStatusBarHUD.podspec
vim CFStatusBarHUD.podspec
Pod::Spec.new do |s|
s.name = "CFStatusBarHUD"//框架名
s.version = "0.0.1"//版本号
s.summary = "一个简单易用的HUD指示器框架"//简介,内容会在pod search *** 的时候显示
s.description = <<-DESC
An easy-to-use HUD indicator framework
DESC //描述
s.homepage = "https://github.com/ziyilixin"//页面协议
s.license = "MIT"//开源协议
s.author = { "CoderCF" => "[email protected]" }//作者
s.platform = :ios, "7.0"//最低支持版本
s.source = { :git => "https://github.com/ziyilixin/CFStatusBarHUD.git", :tag => "#{s.version}" }//源代码地址
s.source_files = "CFStatusBarHUD", "*.{h,m}".//源文件(可以包含.h和.m)
s.requires_arc = true//是否支持arc
end
除此之外根据自身项目的需要添加如下内容
//resources:资源文件(配置的文件都会被放到mainBundle中)
s.resources = 'Resources/MyRes.bundle'
//resource_bundles:资源文件(配置的文件会放到你自己指定的bundle中)
s.resource_bundles = {
'xxx' => ['Resources/MyRes.bundle'],
}
//frameworks:依赖的系统框架
s. frameworks = 'AVFoundation', 'CoreGraphics', 'Security',
//vendored_frameworks:依赖的非系统框架
s. vendored_frameworks = 'Frameworks/libZCPKit.a'
//libraries:依赖的系统库
s.libraries = 'c++.1'
//vendored_libraries:依赖的非系统的静态库
s. vendored_libraries = ''xxx/xxx/*.a''
//dependency:依赖的三方库
s.dependency '项目名','~> 版本号'
3.检查注册过的trunk
pod trunk me
如果已经注册过结果如下,此步可忽略
如果没有注册需要进行注册操作
pod trunk register [email protected] 'CoderCF'
[!] Please verify the session by clicking the link in the verification email that has been sent to [email protected]
登录邮箱去验证
4.上传Git
- 打tag添加描述
git tag -a 0.0.1 -m "0.0.1"
- 推送到远程
git push --tags
- 删除本地tag
git tag -d 0.0.2
- 删除远程tag
git push origin :refs/tags/0.0.1
5.校验.podspec文件
pod lib lint
验证成功如下
-> CFStatusBarHUD (0.0.1)
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
CFStatusBarHUD passed validation.
6.发布
pod trunk push CFStatusBarHUD.podspec
发布成功如下:
Validating podspec
-> CFStatusBarHUD (0.0.1)
- NOTE | xcodebuild: note: Using new build system
- NOTE | [iOS] xcodebuild: note: Planning build
- NOTE | [iOS] xcodebuild: note: Constructing build description
Updating spec repo `master`
CocoaPods 1.7.0.beta.3 is available.
To update use: `sudo gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information, see https://blog.cocoapods.org and the CHANGELOG for this version at https://github.com/CocoaPods/CocoaPods/releases/tag/1.7.0.beta.3
--------------------------------------------------------------------------------
Congrats
CFStatusBarHUD (0.0.1) successfully published
March 28th, 00:50
https://cocoapods.org/pods/CFStatusBarHUD
Tell your friends!
--------------------------------------------------------------------------------
7.检查网址
https://cocoapods.org/pods/CFStatusBarHUD
8.遇到的问题及解决方法
问题
- ERROR | [iOS] unknown: Encountered an unknown error (Malformed version number string ) during validation.
解决方法
sudo gem install -n /usr/local/bin cocoapods
问题
[!] You need to register a session first.
解决方法
pod trunk register [email protected] 'CoderCF'
[!] Please verify the session by clicking the link in the verification email that has been sent to [email protected]
登录邮箱去验证
问题
warning: Could not find remote branch 0.0.1 to clone.
fatal: Remote branch 0.0.1 not found in upstream origin
解决方法
git tag '0.0.1'
git push --tags
问题
框架truck push到CocoaPods成功后使用pod search搜索不到
解决方法
在Finder中,使用快捷键command+shift+G进入
~/Library/Caches/CocoaPods/
删除search_index.json,此文件是pod search搜索时的缓存文件
重新打开终端搜索就可以了。
-> CFStatusBarHUD (0.0.1)
一个简单易用的HUD指示器框架
pod 'CFStatusBarHUD', '~> 0.0.1'
- Homepage: https://github.com/ziyilixin
- Source: https://github.com/ziyilixin/CFStatusBarHUD.git
- Versions: 0.0.1 [master repo]