pod
cocoapods 的安装 ruby 章节
# pod 使用
-> % pod
Usage:
$ 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
+ pdd Cocoapods plugin for Pinduoduo.
+ 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.lock
Options:
--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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 其他
# pod 版本控制
限定次要版本
pod 'Masonry', '~> 1.0.1'pod: 这是 CocoaPods 的命令行工具, 用于管理项目的依赖'Masonry': 这是要添加的第三方库的名称, 即 Masonry', ~> 1.0.1': 这是版本号的范围限制。~>符号表示版本的范围, 它告诉 CocoaPods 可以安装 1.0.1 版本以及更新的次要版本, 但不包括 2.0 及更高的版本。具体来说,~> 1.0.1表示可以安装 1.0.1、1.0.2、1.0.3 等等, 但不包括 2.0 及更高的版本
# podspec 文件
CocoaPods 是一个用于管理和共享代码库的依赖管理器, 它允许开发人员将他们的代码库共享给其他开发人员, 并让其他人能够轻松地将这些库集成到他们的项目中。为了将代码库发布到 CocoaPods, 你需要创建一个 .podspec 文件, 这个文件包含了关于你的库的元数据和依赖信息。以下是 .podspec 文件的一些常见字段和用途:
name: 库的名称version: 库的版本号summary: 一个简短的描述, 用于描述库的用途description: 详细的描述, 用于描述库的功能和用法homepage: 项目的主页或文档链接license: 使用的许可证类型authors: 作者信息source: 代码库的源文件platforms: 库支持的平台和版本dependencies: 依赖的其他 CocoaPods 库source_files: 库中包含的源文件public_header_files: 公共头文件的路径resources: 与库一起安装的资源文件frameworks: 依赖的系统框架vendored_frameworks: 要打包的外部框架vendored_libraries: 要打包的外部库文件prefix_header_file: 预编译的头文件
这只是 .podspec 文件的一部分, 你可以根据你的库的具体情况来添加或修改这些字段。创建完 .podspec 文件后, 你可以使用 pod lib lint 命令来验证它, 确保没有错误, 然后使用 pod trunk push 命令发布你的库到 CocoaPods 仓库, 使其他开发人员能够通过 CocoaPods 来使用你的库
# Unable to find a specification
参考: https://help.aliyun.com/document_detail/51352.html (opens new window)
- 检查 repo:
pod repo list - 确认 lib 是否存在:
pod search <lib> - 更新 repo:
pod repo update或者pod install --repo-update - 添加指定的 source 到 Podfile, 如
source 'https://github.com/CocoaPods/Specs.git'source 'https://github.com/aliyun/aliyun-specs.git'
# pod install vs. pod update (opens new window)
pod install:This is to be used the first time you want to retrieve the pods for the project, but also every time you edit your Podfile to add, update or remove a pod.
Every time the
pod installcommand is run — and downloads and install new pods — it writes the version it has installed, for each pods, in thePodfile.lockfile. This file keeps track of the installed version of each pod and locks those versions.When you run
pod install, it only resolves dependencies for pods that are not already listed in the Podfile.lock.- For pods listed in the
Podfile.lock, it downloads the explicit version listed in thePodfile.lockwithout trying to check if a newer version is available - For pods not listed in the
Podfile.lockyet, it searches for the version that matches what is described in the Podfile (like in pod 'MyPod', '~>1.2')
- For pods listed in the
pod update:When you run
pod update PODNAME,CocoaPods will try to find an updated version of the podPODNAME, without taking into account the version listed inPodfile.lock. It will update the pod to the latest version possible (as long as it matches the version restrictions in yourPodfile).If you run
pod updatewith no pod name, CocoaPods will update every pod listed in your Podfile to the latest version possible.