在用cocoapods安装RestKit之后,我遇到了一个奇怪的问题。 在用cocoapods解决我的项目的RestKit依赖关系并试图构建它之后,我面临这个错误:

沙箱与Podfile.lock不同步。运行“pod install”或更新CocoaPods安装。

我试着运行pod安装,但没有变化。

以下是一些照片:

  PODS:
  - AFNetworking (1.3.3)
  - RestKit (0.20.3):
    - RestKit/Core
  - RestKit/Core (0.20.3):
    - RestKit/CoreData
    - RestKit/Network
    - RestKit/ObjectMapping
  - RestKit/CoreData (0.20.3)
  - RestKit/Network (0.20.3):
    - AFNetworking (~> 1.3.0)
    - RestKit/ObjectMapping
    - RestKit/Support
    - SOCKit
  - RestKit/ObjectMapping (0.20.3)
  - RestKit/Search (0.20.3):
    - RestKit/CoreData
  - RestKit/Support (0.20.3):
    - TransitionKit (= 1.1.1)
  - RestKit/Testing (0.20.3)
  - SOCKit (1.1)
  - TransitionKit (1.1.1)

DEPENDENCIES:
  - RestKit (~> 0.20.0)
  - RestKit/Search (~> 0.20.0)
  - RestKit/Testing (~> 0.20.0)

SPEC CHECKSUMS:
  AFNetworking: 61fdd49e2ffe6380378df37b3b6e70630bb9dd66
  RestKit: 1f181c180105a92f11ec4f6cd7de37625e516d83
  SOCKit: 2f3bc4d07910de12dcc202815e07db68a3802581
  TransitionKit: d0e3344aac92991395d4c2e72d9c5a8ceeb12910

COCOAPODS: 0.29.0

当前回答

Completely nothing worked out for me from these answers. Had to create the project again by running cordova platform add ios. What I've noticed, even freshly generated project with (in my case) Firebase pods caused the error message over and over again. In my opinion looks like a bug for some (Firebase, RestKit) pods in Xcode or CocoaPods. To have the pods included I could simply edit my config.xml and run cordova platform add iOS, which did everything for me automatically. Not sure if it will work in all scenarios though.

编辑:我有一个Podfile从以前的iOS/Xcode,但最新的今天有# DO NOT MODIFY -自动生成的Apache Cordova在Podfile。这让我的脑海中亮起了一盏灯,开始尝试这种方法。看起来有点琐碎,但很管用,我的Firebase功能也很管用。

其他回答

当我添加一个新的开发人员帐户时,我得到了这个错误。我更改了项目名称下的团队,但我错过了在Pods文件夹下更新它。

我在Pods-> Signing -> Team下的Teams选项下更新了新的开发人员ID后解决了这个问题,错误消失了,构建成功。

如果你的舱是空的

删除复制豆荚资源和检查豆荚清单。 从构建阶段锁定项目的设置

我找到了我的解决方案:运行:pod update而不是pod install。错误被修正了!

对我来说,这是Ruby版本号的问题。

我得到了错误:

The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

在尝试了一百万件事情之后,包括这个线程中包含的大部分内容,我最终破解了位于:usr/local/bin/pod的pod文件

我更正了第一行,以指向我的机器上实际存在的ruby版本。我改变了:

#!/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby

to

#!/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby

经过几天的努力,从3级到6级一切都解决了。

首先,您必须了解Podfile。锁就是然后明白什么是Manifest。锁是什么,用在什么地方。

Podfile包含您拥有的每个依赖项的(乐观或精确)版本。锁文件只保存精确的版本。

一旦你安装了pod,所有的pod都会被下载/安装到/pods目录中。你可能想承认,也可能不想。这取决于你的团队。你的团队不能决定他们是否应该提交Podfile。锁不锁。这样团队中的每个开发人员都可以确保他们得到完全相同的版本。

假设您下载了团队的代码。在项目的根目录中,只有Podfile和Podfile。锁,Pods目录没有被提交。 然后执行pod install来创建Pods目录。每个pod的版本快照应该与Podfile.lock中所有pod的版本相匹配。 CocoaPods有一个安全检查,以确保匹配的版本

这就是舱单。锁开始发挥作用。清单。Lock是本地机器创建的锁。它必须与Podfile匹配。在你的repo中,由最后一次提交(导致你的pods的变化)生成的锁。如果不匹配,那就有问题了。

关于清单的文件。锁文件为:

  #     Manifest.lock: A file contained in the Pods folder that keeps track of
  #     the pods installed in the local machine. This files is used once the
  #     exact versions of the Pods has been computed to detect if that version
  #     is already installed. This file is not intended to be kept under source
  #     control and is a copy of the Podfile.lock.

老实说,我只能想到一种情况Manifest。锁和Podfile。锁将不同步:

我的意思是如果你从main分支中拉,你会得到main的Podfile和lock file。如果你对Podfile进行了更改,然后运行pod install,那么你将更新Podfile。锁定和清单。锁定并保持它们同步。没有问题

这样是否可以:

您和您的团队不提交/Pods目录 您的Podfile或Podfile中存在合并冲突。锁上,但没有意识到。或者你没有同时提交Podfile和Podfile.lock 假设Xcode不处理Podfile和Podfile。锁定后,您的项目自然可以成功构建。 然而,如果你去检查你的目标的构建阶段,你会看到以下内容

这里记录了该脚本

#     Adds a shell script build phase responsible for checking if the Pods
#     locked in the Pods/Manifest.lock file are in sync with the Pods defined
#     in the Podfile.lock.
#     
#     @note   The build phase is appended to the front because to fail fast.
#     
#     @return [void]

这些行所做的是:执行一个diff并确保您的Manifest。例如,所有已安装pod版本的本地快照都等于Podfile。锁定,即您的回购当前所有已安装pod版本的快照。

修复可能超级简单,只要确保你的Podfile是你想要的。然后运行pod install。你也不小心改变了你的清单。锁在你的/Pods目录中(或者如前所述,可能只提交锁文件而不提交Podfile,反之亦然)。删除/Pods目录不会造成伤害。然后再做一个吊舱安装。不要更新吊舱,除非你想这么做。

只要确保你没有删除Podfile。锁定,否则如果你做pod安装,那么它将更新所有依赖到最新版本。


这段关于锁文件的视频也很有帮助,CocoaPods文档介绍了锁文件在pod安装和pod更新中的不同用法,最后详细介绍了如何使用所有这些逻辑 这个关于校验和的艺术博客。值得注意的是,单个空格将创建一个新的校验和,并可能使内容不同步。