首先更新了用trunk以后,CocoaPods 须要0.33版本以上的,用 pod --version 查看,若是版本低,须要更新pod 参考guides.cocoapods.org/making/gett…html
$ pod trunk register 邮箱 '用户名' --description='电脑描述'
复制代码
点击邮件的连接就完成了trunk注册流程。ios
cd到项目根目录git
若是未标记tag,验证的时候会 fatal: Remote branch 0.0.1 not found in upstream origin
github
$ git tag '0.0.1'
$ git push --tags
复制代码
$ pod spec create AdAlertView
复制代码
这时候本地就生成一个AdAlertView.podspec文件json
删除没必要要的注释(这里只简单介绍基本用法,因此只用到一部分必须得字段 更多字段请移步http://guides.cocoapods.org/syntax/podspec.html
) 编辑的时候会报以下错误,根据提示修改便可 缓存
参照:bash
s.name = "verifyNumberCode"
s.version = "0.0.1"
s.summary = "A short description of verifyNumberCode."
s.description = "实现短信验证码验证"
s.homepage = "https://github.com/IT-iOS-xie/verifyNumberCode.git"
s.license = "MIT"
s.license = { :type => "MIT", :file => "FILE_LICENSE" }
s.author = { "xie" => "*********@qq.com" }
s.social_media_url = "http://twitter.com/xie"
s.platform = :ios
s.source = { :git => "https://github.com/IT-iOS-xie/verifyNumberCode.git", :tag => "0.0.1" }
s.source_files = "Classes", "verifyNumberCode/*.{h,m}"
s.exclude_files = "Classes/Exclude"
s.public_header_files = "verifyNumberCode/*.h"
s.requires_arc = true
复制代码
podSpec
中spec
的全称是Specification
,说明书的意思。顾名思义,这是用来描述你这个私有pod的说明信息的。 podSpec
是cocoapods
的一种文件格式,有一套本身的语法,咱们能够到cocoapods官网进行详细了解(guides.cocoapods.org/syntax/pods…)。框架
建立podSpec
很简单,只要建立一个以.podSpec
为后缀的文件便可,或者直接拷贝别人的进行修改也能够。编辑器
它的建立命令是:$pod spec create TestFile
ide
podspec
文件的经常使用配置字段介绍
框架名字:框架名字必定要写对,pod search
"框架名"就是搜的这个
s.name= "yoowei"
复制代码
框架版本号
s.version= "1.0.0"
复制代码
框架简介
s.summary= "yoowei框架"
复制代码
框架的主页
s.homepage= "https://git.oschina.net/yoowei"
复制代码
框架遵照的开源协议
s.license = 'MIT'
复制代码
框架的做者
s.author = { "yoowei" => "yoowei@126.com" }
复制代码
框架的资源路径:路径能够指向远端代码库,也能够指向本地项目,例如: 1.指向远端代码库: { :git => "git@git.oschina.net:yoowei/yoowei.git", :tag => "1.0.0" }
2.指向本地项目: { :path => 'yoowei', }
s.source = { :git => "git@git.oschina.net:yoowei/yoowei.git", :tag => "1.0.0" }
复制代码
框架被其余工程引入时,会导入yoowei目录下的.h和.m文件
s.source_files = 'yoowei/**/*.{h,m}'
复制代码
框架被其余工程引入时,会导入yoowei/resource
目录下的资源文件
s.resources = {
'yoowei' => ['yoowei/resource/**/*.{storyboard,xcassets,xib,png']
}
复制代码
框架依赖的framework
s.framework = 'CoreData'
复制代码
框架依赖的其余第三方库
s.dependency 'MagicalRecord', :git => 'https://github.com/iiiyu/MagicalRecord.git', :tag => 'sumiGridDiary2.1'
s.dependency 'MBProgressHUD'
复制代码
框架是否须要支持ARC
s.requires_arc = true
复制代码
框架支持的最低平台版本
s.platform = :ios, '7.0'
复制代码
框架公开的头文件
s.public_header_files = 'yoowei/**/*.h'
复制代码
编辑完podspec文件后须要验证一下这个文件是否可用podspec文件不容许有任何的Warning或者Error 执行命令
$ pod lib lint
复制代码
有事会出现部分警高
$ pod lib lint --allow-warnings
复制代码
push
podspec
文件$ pod trunk push AdAlertView.podspec
复制代码
$ pod trunk push AdAlertView.podspec --allow-warnings
复制代码
若是此时报下面的错误,没有设置tag
咱们如今就可使用pod search adalertview
[!] Unable to find a pod with name, author, summary, or description matching
adalertview`` 1.Finder前往资源库去删除缓存中的
search_index.json
(xie修改为你本身的)
/Users/xie/Library/Caches/CocoaPods
删除
search_index.json
或执行
rm ~/Library/Caches/CocoaPods/search_index.json
复制代码
而后再输入pod search
时会从新建立这个search_index.json
有时候发布完可能须要等一段时间才能搜索到。