OC 代码上传到cocoapods

****遇到一个坑****,****之前电脑里装有****cocoapods,****后来升级电脑到最新系统****,****可运行到后面的时候发现提示我说****cocoapods****找不到了****,****如果你也有此情况****,****请看我的这篇文章

解决Mac OS X 10.11更新以后Cococapods找不到问题
升级10.11的系统以后执行 pod install 的时候报错

  • 一 在工程根目录中初始化一个Podspec文件


    Paste_Image.png
  • 二 创建 podspec文件
    pod spec create STRowLayout 之后会生成STRowLayout.podspec文件

  • 三 最好下载个Sublime程序(也可以是别的编辑器,可以百度自己找一下),专门用于编辑podspec(因为直接用系统的编辑器打开被坑过,(。・∀・)ノ゙)


    Paste_Image.png
  • 四 用sublime编写下面的代码,注意要写清楚,不然会报错

Pod::Spec.new do |s|
# 项目名称
s.name         = 'STRowLayout' 
# 描述一下项目的作用
s.summary      = 'On the basis of STRowLayout encapsulation.'
# 版本号
s.version      = '1.0.1'
# 开源许可证
s.license      = { :type => 'MIT', :file => 'LICENSE' }
# 作者信息
s.authors      = { 'CoderST' => '694468528@qq.com' }
# 所支持的系统以及版本号
s.platform     = :ios, '7.0'
# 项目首页
s.homepage     = "https://github.com/CoderST/RowFayout"
# 资源地址链接
s.source       = { :git => 'https://github.com/CoderST/RowFayout.git', :tag => s.version.to_s }
# 是否支持arc
s.requires_arc = true
# 文件
s.source_files = 'STRowLayout/**/*.{h,m}'
# 头文件
s.public_header_files = 'STRowLayout/*.{h}'
# 所用到的系统类库
s.frameworks = 'Foundation', 'UIKit'
# 所用到 cocoapods 中的其他类库
#s.dependency 'AFNetworking', '~>3.1.0'
end

注意:如果上面是swift的话要改为{swift}
s.source_files = 'STRowLayout/*/.{swift}'

 - ERROR | name: The name of the spec should match the name of the file.
 - ERROR | [iOS] file patterns: The `source_files` pattern did not match any file.
  • 1 出现上面第一个错误的时候,是因为s.name 要写成你上传到cocoapods上文件的名称,而不是你xcode新建项目的名称
  • 2 出现这个错误就比较蛋疼了,在自己的房子了搞了一晚上都没有搞好,第二天到公司,打开电脑,就在试了一下 "pod spec lint STRowLayout.podspec" 结果好了~~😆 也是醉了,怀疑更网络有关系!
  • 五 编写后记得git一下
git add .
git commit -m"改动的内容"
git push
  • 六 给项目打tag
git tag '1.0.1' 
git push --tags 
  • 七 此部非常重要,如果错误会报错误(经常会出现的错误-第八步骤,出现错误慢慢调),此处的STRowLayout.podspec改为你自己的podspec
    pod spec lint STRowLayout.podspec
    Paste_Image.png

    看到上面的截图,恭喜你,说明你已经验证通过啦!!!
  • 八 报错信息
RowFayout git:(master) pod spec lint STRowLayout.podspec           

 -> STRowLayout (1.0.0)
    - ERROR | file patterns: The `source_files` pattern did not match any file.

Analyzed 1 podspec.

[!] The spec did not pass validation, due to 1 error.
  • 九 如果上面一部通过,恭喜你💐 已经进行一大半了,下面就是 - 注册trunk
    pod trunk register 694468528@qq.com 'CoderST' -- verbose
    建议邮箱与Github的保持一致,这样提交日志上面就会显示你的Github账号

  • 十 查看自己注册信息
    pod trunk me

  • 十一 提交
    pod trunk push
    有时可能会出现如下错误:[!] There was an error pushing a new version to trunk: getaddrinfo: nodename nor servname provided, or not known
    大体是因为网络导致的,过一会儿再试试就行了(心中有一万个草泥马飞过~~)

    Paste_Image.png

    出现这个图恭喜,你已经上传成功cocoapods

  • 十二 别慌恭喜和草泥马,以为成功了 在pod search STRowLayout 出现下面错误

    Paste_Image.png

    卧槽这成功更失败有什么区别,既然说找不到!!!!
    于是在找答案,可以用下面的命令试试
    rm ~/Library/Caches/CocoaPods/search_index.json
    Paste_Image.png

    在pod search STRowLayout
    Paste_Image.png

这下终于KO了~~😊


Paste_Image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容