离久的小站

使用Bundle命令来兼容Cocoapods

2018/06/08 Share

使用Bundle命令来兼容Cocoapods

安装 Bundler && 创建 Gemfile

1
gem install bundler

若需要权限则使用 sudo

1
sudo gem install bundler

Gemfile

Gemfile是我们创建的一个用于描述gem之间依赖的文件。gem是一堆Ruby代码的集合,它能够为我们提供调用。你的Gemfile必须放在项目的根目录下面, 这是Bundler的要求,对于任何的其他形式的包管理文件来说,这也是标准。这里值得注意的一点是Gemfile会被作为Ruby代码来执行。当在Bundler上下文环境中被执行的时能使我们访问一些方法,我们用这些方法来解释gem之间的require关系。

你可以理解为:

  1. Cocoapods是一个第三方库
  2. Bundler是管理这些第三方库的“大Cocoapods”
  3. Gemfile 就是 Bundler 的 Podfile

创建Gemfile

1
bundle init

Gemfile 内容

1
2
3
4
5
6
7
source "https://rubygems.org"

gem 'cocoapods', '1.6.0' ##指定pod版本

gem 'cocoapods-links', '0.3.0' #:git => 'git@gitlab.xxx.xxxx.com:_ios/cocoapods-###指定git仓库地址

links.git', :tag=>'0.4.0' ###指定podlinks版本

使用

先在 Bundler 中安装 Gemfile 中的组件

这里不需要用sudo,也最好不要用sudo

1
bundle install

使用 pod 命令为:

1
bundle exec + pod 语句

例如:

1
2
bundle exec pod install --verbose --no-repo-update
bundle exec pod update --verbose --no-repo-update

其它

查看本机安装的pod版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
gem list --local | grep cocoapods

cocoapods (1.7.3, 1.5.3, 1.2.1, 0.39.0)
cocoapods-core (1.7.3, 1.5.3, 1.2.1, 0.39.0)
cocoapods-deintegrate (1.0.4, 1.0.2)
cocoapods-downloader (1.2.2, 1.2.1, 0.9.3)
cocoapods-links (0.3.0)
cocoapods-mangle (1.0.1)
cocoapods-packager (1.5.0)
cocoapods-plugins (1.0.0, 0.4.2)
cocoapods-search (1.0.0, 0.1.0)
cocoapods-stats (1.0.0, 0.6.2)
cocoapods-trunk (1.3.1, 0.6.4)
cocoapods-try (1.1.0, 0.5.1)

安装pod

安装pod link工具:

1
sudo gem install cocoapods-links

安装指定版本的pod:

1
sudo gem install cocoapods -v 1.6.0
CATALOG
  1. 1. 使用Bundle命令来兼容Cocoapods
    1. 1.1. 安装 Bundler && 创建 Gemfile
    2. 1.2. Gemfile
      1. 1.2.1. 创建Gemfile
      2. 1.2.2. Gemfile 内容
    3. 1.3. 使用
    4. 1.4. 其它
      1. 1.4.1. 查看本机安装的pod版本
      2. 1.4.2. 安装pod