“分离舱回收更新”到底是做什么的?

我正在学习 Firebase 上的一个互联网教程,作为其中的一部分,我必须在命令行上做一些工作。我对命令行很熟悉,但对 Cocoapods 不熟悉。我运行了 pod repo update,但这样做之后,我意识到我运行它在我的整个文档文件夹,我的 Mac 而不是文件夹中包含我的项目。我花了超过20分钟的时间来执行,当它最终完成的时候,它打印出了数以千计的东西,其中一些包括“创建”和“删除”。我有点担心——运行这个命令会不会修改我的文档中除了 Firebase 项目之外的任何内容?那 pod repo update又能做些什么呢?

103796 次浏览

As per the documentation pod repo update updates the spec repos located at ~/.cocoapods/repos in your home folder.

Updates the local clone of the spec-repo NAME. If NAME is omitted this will update all spec-repos in ~/.cocoapods/repos.

The repo is basically a list of all pods and versions available. I have just encountered an error in our CI builds because the repo did not include a spec for a library I have just added. By running pod repo update it now knows of this newer version and can continue to install it.

So to answer your question.. Running pod repo update in your documents folder will not do anything in that folder. It will update its pod spec references in your ~/.cocoapods/repos folder only.

The main Specs repo is nothing but a list of ALL PodSpecs. A PodSpec is:

A specification describes a version of Pod library. It includes details about where the source should be fetched from [which tag or commit or branch], what files to use, the build settings to apply, and other general metadata such as its name, version, and description.

The specs directory is nothing but a list of all distinct PodSpecs. Each version of the PodSpec is under a tag directory. The repo doesn't contain the pod itself. The repo contains the PodSpec. The PodSpec gives the location of the repo and a bunch of other meta data⚡︎

spec.source = { :git => 'https://github.com/tonymillion/Reachability.git', :tag => 'v3.1.0' }

When you do pod repo update, you're pulling the latest PodSpecs (not the actual pod) from https://github.com/CocoaPods/Specs. If you want to only update an individual pod source, then just do pod repo update [NAME]

Cocoapods/Specs master repo:

enter image description here

The list of some Alamofire PodSpecs

enter image description here

A single PodSpec 4.7.3:

enter image description here


⚡︎: PodSpec: A specification describes a version of Pod library. It includes details about where the source should be fetched from, what files to use, the build settings to apply, and other general metadata such as its name, version, and description.


Your actual project pulls in the code through either pod update or pod install then the physical files get downloaded to your mac and copied for your project.

Often you'd get this error:

None of your spec sources contain a spec satisfying the dependencies: AlamoFire (= 11.0.3), AlamoFire (= 11.0.3).

You have either: * out-of-date source repos which you can update with pod repo update or with pod install --repo-update. * mistyped the name or version. * not added the source repo that hosts the Podspec to your Podfile.

Spec sources is what's important. It just means you haven't pulled in the specs. You can easily see spec sources you have by doing pod repo. Mine is:

cocoapods
- Type: git (remotes/origin/master)
- URL:  https://github.com/CocoaPods/Specs.git
- Path: /Users/mfaani/.cocoapods/repos/cocoapods


private_pods
- Type: git (master)
- URL:  git@github.company.com:xyz/private_Cocoapods.git
- Path: /Users/mfaani/.cocoapods/repos/private_cocoapods


trunk
- Type: CDN
- URL:  https://cdn.cocoapods.org/
- Path: /Users/mfaani/.cocoapods/repos/trunk