0%

Pod常用命令

简介

介绍Pod常用的几种命令

pod init

第一次调用会初始化项目,如果已经初始化后调用会抛出以下错误。

[!] Existing Podfile found in directory

pod install

根据podfile.lock文件中指定的pod依赖库的版更新项目的pod依赖库。在首次执行pod install命令时,如果不存在podfile.lock文件会生成该文件,并且同时生成xcworkspace文件和pods文件夹。

pod install执行后,后续的项目需要使用xxx.xcworkspace打开

参数:–no-repo-update

不更新pod仓库,使用此命令可以加快pod install的更新速度。

eg: pod install --no-repo-update

pod update

这个命令会检查podfile.lock文件中的pod依赖库的版本,并更新,会重新生成一个新podfile.lock文件。

选项:–exclude-pods=xxx

只更新xxx之外的仓库。

eg: pod update --exclude-pods=AFNetworking

选项:xxx –no-repo-update

只更新xxx依赖不更新除它之外的其他依赖。

eg: pod update AFNetworking --no-repo-update

一般没有特别必要时不建议使用pod update命令,尽量使用pod install,如果实在不行再使用带上面选项的od update,如果更新失败才使用pod update命名,这样能明显加快更新流程,节约更新依赖的时间。

后面更新依赖库的名称,搜索指定依赖库

eg: pod search AFNetworking

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-> AFNetworking (3.2.1)
A delightful iOS and OS X networking framework.
pod 'AFNetworking', '~> 3.2.1'
- Homepage: https://github.com/AFNetworking/AFNetworking
- Source: https://github.com/AFNetworking/AFNetworking.git
- Versions: 3.2.1, 3.2.0, 3.1.0, 3.0.4, 3.0.3, 3.0.2, 3.0.1, 3.0.0,
3.0.0-beta.3, 3.0.0-beta.2, 3.0.0-beta.1, 2.7.0, 2.6.3, 2.6.2, 2.6.1, 2.6.0,
2.5.4, 2.5.3, 2.5.2, 2.5.1, 2.5.0, 2.4.1, 2.4.0, 2.3.1, 2.3.0, 2.2.4, 2.2.3,
2.2.2, 2.2.1, 2.2.0, 2.1.0, 2.0.3, 2.0.2, 2.0.1, 2.0.0, 2.0.0-RC3, 2.0.0-RC2,
2.0.0-RC1, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.1, 1.2.0, 1.1.0, 1.0.1,
1.0, 1.0RC3, 1.0RC2, 1.0RC1, 0.10.1, 0.10.0, 0.9.2, 0.9.1, 0.9.0, 0.7.0,
0.5.1 [master repo]
- Subspecs:
- AFNetworking/Serialization (3.2.1)
- AFNetworking/Security (3.2.1)
- AFNetworking/Reachability (3.2.1)
- AFNetworking/NSURLSession (3.2.1)
- AFNetworking/UIKit (3.2.1)

pod repo

查看所有pod 仓库的源

1
2
3
4
master
- Type: git (master)
- URL: https://github.com/CocoaPods/Specs.git
- Path: /Users/wangruofeng/.cocoapods/repos/master

选项:remove xxx

eg: pod repo remove xxx

移除xxx repo源

pod try

非常棒,却很少有人知道,使您可以在将库添加到项目之前对其进行测试驱动。

选项:try xxx

1
pod try AFNetworking

pod outdated

显示当前 Podfile.lock文件中过期的pods,仅仅是来自spec repos,不包含来自本地和外部的资源。

pod_outdated

gem source 操作

当前gem源查看

gem source -l

1
2
3
*** CURRENT SOURCES ***

https://gems.ruby-china.com/

移除指定的gem源

gem source - - remove https://rubygems.org/

添加指定的gem源

gem source - a https://gems.ruby-china.com/

更新cocoapod

sudo gem install cocoapods