搜索
您的当前位置:首页正文

Private Pods(译)

来源:二三娱乐

1. 创建一个私有的仓库

2. 添加你的私有库到你的CocoaPods中

$ pod repo add REPO_NAME SOURCE_URL

注意:如果你打算创建本地pods,你应该推到这个资源地址上

检查你是否成功安装

$ cd ~/.cocoapods/repos/REPO_NAME
$ pod repo lint .

3. 添加你的Podspec到你的仓库

确定你已经给你的代码资源打上tag和版本,然后运行

$ pod repo push REPO_NAME SPEC_NAME.podspec

这将会运行pod spec lint,注意在你私有库配置spec时所有的小细节。
你仓库的结构应该是这样的

.
├── Specs
    └── [SPEC_NAME]
        └── [VERSION]
            └── [SPEC_NAME].podspec

就是这样

你的私有Pod已经可以用于在Podfile里了。你能在你的Podfile中通过资源指令来使用私有库,比如下面的例子中展示。

一个示例

1. 创建一个私有的仓库

在你的服务器上创建一个仓库。可以是在Github上或者是你自己的服务器如下

$ cd /opt/git
$ mkdir Specs.git
$ cd Specs.git
$ git init --bare

2. 添加你的私有库到你的CocoaPods中

使用你服务器上的仓库的URL,添加你的仓库使用:

$ pod repo add artsy-specs git@github:artsy/Specs.git

检查你是否安装成功使用:

$ cd ~/.cocoapods/repos/artsy-specs
$ pod repo lint .

3. 添加你的Podspec到你的仓库

创建你的Podspec

cd ~/Desktop
touch Artsy+OSSUIFonts.podspec

Artsy+OSSUIFonts.podspec 应该会在你选择的文本编辑器里打开. 典型的内容应该是:

Pod::Spec.new do |s|
  s.name             = "Artsy+OSSUIFonts"
  s.version          = "1.1.1"
  s.summary          = "The open source fonts for Artsy apps + UIFont categories."
  s.homepage         = 
  s.license          = 'Code is MIT, then custom font licenses.'
  s.author           = { "Orta" =>  }
  s.source           = { :git =>  :tag => s.version }
  s.social_media_url = 

  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

保存你的Podspec,然后添加到仓库中

pod repo push artsy-specs ~/Desktop/Artsy+OSSUIFonts.podspec

如果你的Podspec是有效的,它将会被添加到仓库里。仓库将会看着像这样:

.
├── Specs
    └── Artsy+OSSUIFonts
        └── 1.1.1
            └── Artsy+OSSUIFonts.podspec

如何移除私有库

pod repo remove [name]

外部资源

Top