制作自己的Cocoapod

注册trunk

$ pod trunk register [email protected] 'Alex’ #注册,会发带验证链接的邮件到邮箱地址,名称无法修改。

生成podspec文件
 $ pod spec create DTableViewPlaceHolder

会在当前目录下生成DTableViewPlaceHolder.podspec文件,里面有非常多的注释,大部分都是无用的。建议删除内容,直接使用其它成功提交的podspec文件修改。

Pod::Spec.new do |s|
    s.name         = "DTableViewPlaceHolder"
    s.version      = "0.0.2"
    s.summary      = "TableView PlaceHolder."
    s.description  = <<-DESC
                    this is TableView PlaceHolder.
                   DESC
    s.homepage     = "https://github.com/destinyzhao/DTableViewPlaceHolder"
    s.license          = { :type => 'MIT', :file => 'LICENSE' }
    s.author           = { 'Destiny' => '[email protected]' }
    s.source           = { :git => 'https://github.com/destinyzhao/DTableViewPlaceHolder.git', :tag => s.version.to_s }
    s.ios.deployment_target = '10.0'
    s.source_files = 'DTableViewPlaceHolder/**/*.{h,m}'

end
打tag
  $ git tag 0.0.2    #给源代码打版本标签,与podspec文件中version一致即可
  $ git push --tags
验证本地podspec文件是否合法
  $ pod lib lint    //需要验证一下,以便提前发现问题。
  $ pod spec lint --allow-warnings  //忽略警告

更新GitHub仓库

 $ git add .                   #将当前目录下所有文件和子目录的修改记录到Git索引中
 $ git status                  #列出当前目录下被修改还未提交的状态
 $ git commit -m ‘first commit’     #提交被add的改动
 $ git push origin master           #push代码到Git

验证远程podspec文件是否合法
$ pod spec lint 
$ pod spec lint --allow-warnings // 忽略警告
$ pod lib lint  --allow-warnings  --use-libraries (引用其他第三方库)
发布到CocoaPods
 $  pod trunk push DTableViewPlaceHolder.podspec --use-libraries --allow-warnings

等待成功如下图


2416132-0fe424ed5c81b055.png
屏幕快照 2019-01-23 18.15.59.png
可能出现问题1

如出现 Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.

按照如下步骤:
pod trunk register 你的邮箱
打开邮箱验证
重新执行pod trunk push podspec 提交podspec文件
可能出现问题2

trunk push 到 CocoaPods 成功后 pod search 却搜不到。
~/Library/Caches/CocoaPods/


2416132-d0ce2f6410b736e4.png
屏幕快照 2019-01-23 18.23.28.png

删除 search_index.json 这个文件,这个文件是 pod search 搜索时的缓存文件。

猜你喜欢

转载自blog.csdn.net/weixin_34203426/article/details/87474704