创建自己的CocoaPods库

创建自己的CocoaPods库

前期准备:

  1. 准备好自己的代码库,本文以github上的代码库为例,可参考作者的工程:LYCopyLabel

  2. 注册trunk(已注册过的请跳过):

    // 升级pods至最新版本
    $ sudo gem install cocoa pods
    // 进行注册 邮箱和GitHub用户名字
    $ pod trunk register example@xxx.com 'GithubUserName' --verbose 
    // 根据提示点击邮箱链接进行验证 完成注册
  3. 查看注册是否成功:

     $ pod trunk me
     //返回如下表示注册成功
    - Name:     GithubUserName
    - Email:    example@xxx.com
    - Since:    May 13th, 11:19
    - Pods:     None
    - Sessions:

正式开始

  1. 创建.podspec仓库文件:

    //创建仓库文件
    $ pod spec create LYCopyLabel
    // 返回如下
    Specification created at LYCopyLabel.podspec
  2. 编辑.podspec文件,可以根据内容提示自己编辑,也可以参考比较知名的三方库的该文件进行编辑。

    $ vim LYCopyLabel.podspec
    //编辑文本 
    Pod::Spec.new do |s|
    
    s.name         = "LYCopyLabel"
    s.version      = "1.0.1"
    s.summary      = "Sub Class of UILabel to make the label enable to be copyed when long pressed"
    
    s.homepage     = "https://github.com/liuyang20091130/LYCopyLabel"
    
    s.license      = 'MIT'
    
    s.author       = { "liuyang20091130" => "example@xxx.com" }
    
    s.platform     = :ios
    s.platform     = :ios, "5.0"
    
    s.source       = { :git => "https://github.com/liuyang20091130/LYCopyLabel.git", :tag => "#{s.version}" }
    
    
    s.source_files  = "CopyLabel/LYCopyLabel/*.{h,m}"
    
    s.public_header_files = "CopyLabel/LYCopyLabel/*.h"
  3. 使用 pod lib lint验证.podspec文件的正确性。若出现错误需根据提示执行第2步进行修改。

    //执行
    pod lib lint LYCopyLabel.podspec
    //正确返回
    -> LYCopyLabel (1.0.1)
    LYCopyLabel passed validation.

    有可能出现的提示:- WARN | source: The version should be included in the Git tag. ,则需要给git添加tag。tag要与.podspec文件中s.source :tag相同。

      $ git tag '1.0.1'
      $ git push --tags
  4. 推送pod代码库到远程仓库,耐心等待返回。

    //执行
    pod trunk push LYCopyLabel.podspec 
    
    //返回如下表示成功
    -> LYCopyLabel (1.0.1)
       Sub Class of UILabel to make the label enable to be copyed when long pressed
       pod 'LYCopyLabel', '~> 1.0.1'
       - Homepage: https://github.com/liuyang20091130/LYCopyLabel
       - Source:   https://github.com/liuyang20091130/LYCopyLabel.git
       - Versions: 1.0.1 [master repo]
    ESCOC
    
    --------------------------------------------------------------------------------
     ��  Congrats
    
     ��  LYCopyLabel (1.0.1) successfully published
     ��  May 13th, 11:59
     ��  https://cocoapods.org/pods/LYCopyLabel
     ��  Tell your friends!
  5. 使用pods search搜索自己的pod库验证下,大功告成。

    $ pod search LYCopyLabel
    // 返回如下,大功告成。
    -> LYCopyLabel (1.0.1)
    Sub Class of UILabel to make the label enable to be copyed when long pressed
    pod 'LYCopyLabel', '~> 1.0.1'
    - Homepage:https://github.com/liuyang20091130/LYCopyLabel
    - Source: https://github.com/liuyang20091130/LYCopyLabel.git
    - Versions: 1.0.1 [master repo]
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值