一、建立github远程仓库
1.点击绿色按钮新建

2.填写仓库信息

点击create repository 新建仓库
二、本地拉取远程仓库
方法一:
步骤一:cd到需要创建的本地仓库的目录下
步骤二:创建本地仓库
git init
步骤三:关联本地仓库与远程仓库
git remote add origin 远程仓库地址
步骤四:pull远程仓库文件
git pull orgin master
步骤五:将本地仓库文件push到远程
git add.
git commit - m "init"
git push origin master
方法二:
步骤一:用sourcetree建立连接

步骤二:提交代码

三、注册trunk
步骤一:执行指令
1.sudo gem install cocoapods 更新cocospods版本
2.pod trunk register email 'username' --verbose 注册一个邮箱和用户名
步骤二:查看个人注册信息

四、配置podspec文件
步骤一:创建podspec文件
pod spec create YMConfigSpecManager.podspec
步骤二:编辑podspec文件内容
Pod::Spec.new do |s|
s.name = "文件名字" 需要与git上的名字相同
s.version = "0.0.1" 版本号
s.summary = "this is test pod trunk" 描述
s.homepage = "https://github.com/xxx/xxx" git上面的仓库地址
s.license = "MIT"
s.author = { "username" => "email" }
s.source = { :git => "https://github.com/xxx/xxx.git", :tag => '0.0.3' }
s.vendored_frameworks = "xxx/xxx.framework" framework的路劲
s.dependency 'YYModel' framework是否依赖于第三方库,多个写多遍
s.dependency 'AFNetworking'
s.requires_arc = true
s.platform = :ios
end
步骤三:检查podspec文件的可行性
pod lib lint --no-clean
若没有出现error则执行步骤四
可能遇到的一些问题:
1.遇到以下问题可查看文件路劲是否填写正确

2.遇到以下问题代表上传的framework编译失败,查看framework是否依赖于别的第三方库,
若有则在podspec中添加s.dependency 'YYModel'代码,多个添加多行

步骤四:添加tag
pod tag 查看tag
pod tag '0.0.1' 添加tag
git push --tags 上传tag
步骤五:上传文件到cocospod
pod trunk push --allow-warnings
若成功则出现下图的结果

可能遇到的问题:
1.tag没有push

步骤六:查看上传文件
pod search 文件名
若出现

方法一:若之前没有提交过pod,那么trunk之后需要去Claim your Pod认领以下
方法二:pod setup 执行更新pod仓库命令,在执行search命令
方法三:重新创建search_index.json文件
如果pod setup执行完后还不能pod search到,
可以将"/User/UserName/Library/Caches/CocoaPods"下的"search_index.json"文件删掉,
然后再执行pod search时会重新创建这个search_index.json文件。
参考
网友评论