CocoaPods 创建私有库

2020-04-08  本文已影响0人  一个魔法师

一、新建项目

  1. 创建远程仓库(这里以github为例子)
  2. clone下来
  3. 创建项目
  4. 新建放置pod库配置文件的远程仓库

二、新建本地pod库

  1. 添加本地pod仓库
    • git pod repo add 本地仓库名称 上面创建放置配置文件的git地址

三、新建.podspec文件

  1. 在clone下来的仓库的根目录下(不在根目录也行)创建.podspec结尾的文件

  2. 添加配置

    Pod::Spec.new do |s|
      s.name             = "Artsy+OSSUIFonts"
      //版本号,亦是将来你的私有工程要打上的tag号 
      s.version          = "1.1.1"
      s.summary          = "The open source fonts for Artsy apps + UIFont categories."
      s.homepage         = "https://github.com/artsy/Artsy-OSSUIFonts"
      s.license          = 'Code is MIT, then custom font licenses.'
      s.author           = { "Orta" => "orta.therox@gmail.com" }
      s.source           = { :git => "https://github.com/artsy/Artsy-OSSUIFonts.git", :tag => s.version }
      s.social_media_url = 'https://twitter.com/artsy'
    
      s.platform     = :ios, '7.0'
      s.requires_arc = true
    
      s.source_files = 'Pod/Classes'
      s.resources = 'Pod/Assets/*'
    
      s.frameworks = 'UIKit', 'CoreText'
      s.module_name = 'Artsy_UIFonts'
    end
    

四、项目提交打上tag

  1. 项目提交远程仓库
  2. 打上tag(上面.podspec对应的tag号)

五、验证

  1. cd 到.podspec文件的目录下
  2. pod repo lint .
  3. 有问题的按照提示处理问题
  4. pod repo push 项目名称 xxx.podspec
  5. 恭喜!大功告成 去项目中pod 吧,不过需要注意要指定你的pod库的远程配置文件的路径,也就是source xxxxxxxx

六、pod库升级

  1. 修改项目,提交项目,打上tag
  2. 修改.podspec文件对应的版本号
  3. pod repo push 项目名称 xxx.podspec --verbose --use-libraries --allow-warnings

七、遇到的一些小坑

  1. 本地pod库被删了,无法pod repo push,只需要再执行一遍

    git pod repo add 本地仓库名称 上面创建放置配置文件的git地址

  2. pod库升级后,新的项目中引入的还是旧的库版本,需更新下本地的repo

    pod repo update

上一篇 下一篇

猜你喜欢

热点阅读