ios开发中pod命令介绍

来源:互联网 发布:软件防止破解 编辑:程序博客网 时间:2024/05/23 23:08

现在很多项目都是用pod的方式,来解决项目依赖,所以在此做一个pod命令相关的介绍来辅助自己的使用。
使用pod –help可以查看pod可以使用的命令:

>pod --helpUsage:    $ pod COMMAND      CocoaPods, the Cocoa library package manager.Commands:    + cache         Manipulate the CocoaPods cache    + deintegrate   Deintegrate CocoaPods from your project    + env           Display pod environment    + init          Generate a Podfile for the current directory    + install       Install project dependencies according to versions from a                    Podfile.lock    + ipc           Inter-process communication    + lib           Develop pods    + list          List pods    + outdated      Show outdated project dependencies    + plugins       Show available CocoaPods plugins    + repo          Manage spec-repositories    + search        Search for pods    + setup         Setup the CocoaPods environment    + spec          Manage pod specs    + trunk         Interact with the CocoaPods API (e.g. publishing new specs)    + try           Try a Pod!    + update        Update outdated project dependencies and create new                    Podfile.lockOptions:    --silent        Show nothing    --version       Show the version of the tool    --verbose       Show more debugging information    --no-ansi       Show output without ANSI codes    --help          Show help banner of specified command

我们使用较多的是pod install,pod update,pod setuppod search命令。

  • pod install:会根据podfile.lock文件中指定的pod依赖库的版本去拉去项目的pod依赖库。在首次执行pod install命令时,如果不存在podfile.lock文件会生成,podfile.lock文件,并且同时生成xcworkspace文件和pods文件夹。 切换到工程目录执行:
    > pod install
    Analyzing dependencies
    Pre-downloading: `AfantySDK` from
  • pod update:这个命令会检查podfile.lock文件中的pod依赖库的版本,并进行更新,会重新生成一个podfile.lock文件。
  • pod setup:用来初始化cocoapod的环境,在我们刚安装完cocoapod时,我们可以使用pod setup命令来初始化pod的运行环境,具体实现:是通过在~/.cocoapods/repos下创建一个目录,该目录是通过clonehttps://github.com/CocoaPods/Specs`的public master分之得到的pod仓库,在一些企业开发中,经常会有自己的pod仓库,只需将这些仓库使用一下方式添加到该目录下即可:

    pod repo add NAME URL[branch]
    使用自己的pod仓库,会有更快的pod依赖库的操作速度。

  • pod search:该命令用来搜索可以使用的pod依赖库,搜索结果中会向我们展示怎么在pod中使用该依赖库。

其他还有一些使用较少的pod命令可以作为了解:

  • pod list:列出所有项目依赖仓库中的pod依赖库。
  • pod repo:用来管理pod依赖仓库的地址。
  • pod spec:管理pod规范。
  • pod init:在当前目录下创建一个podfile文件,我们可以通过将需要的pod依赖库添加到podfile文件中,实现在项目中添加依赖。
  • pod env:来打印出pod的环境,一般是podfile文件中的内容。
  • pod cache:管理cocoapod的缓存:可以用来清空内存,也可以用来查看每个pod库的缓存。
  • pod outdate:展示出可更新版本的pod依赖库。
0 0