Cocoapod 的 Xcode 错误:“无法保存文档。文件不存在”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28444966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:37:57  来源:igfitidea点击:

Xcode error with Cocoapod: "The document could not be saved. The file doesn’t exist"

iosobjective-cxcodecocoacocoapods

提问by H K

I've added the SPGooglePlacesAutocompletecocoapod to my project -- and I'm getting a really weird issue. When I try to run my project, Xcode says there's an error in one of the Pod's headers:

我已经将SPGooglePlacesAutocompletecocoapod添加到我的项目中——但我遇到了一个非常奇怪的问题。当我尝试运行我的项目时,Xcode 说 Pod 的标头之一中存在错误:

SPGooglePlacesAutocompleteQuery.h:65:23: Unknown type name 'CGFloat'

SPGooglePlacesAutocompleteQuery.h:65:23: Unknown type name 'CGFloat'

Attempting to adjust anything in that file - such as importing UIKit - results in an error: "The document SPGooglePlacesAutocompleteQuery.h could not be saved. The file doesn't exist"

尝试调整该文件中的任何内容 - 例如导入 UIKit - 会导致错误:“无法保存文档 SPGooglePlacesAutocompleteQuery.h。该文件不存在”

What could be making Xcode thing this file is non-existent?

是什么让 Xcode 成为这个文件不存在的原因?

回答by Damien Sirkis

For what it's worth, in my case the error came up when I was trying to edit a file pointed to by the warning/error pane in Xcode.

对于它的价值,在我的情况下,当我尝试编辑由 Xcode 中的警告/错误窗格指向的文件时出现错误。

Not sure if that's cocoa pod related but I happen to be using pods also.

不确定这是否与可可豆有关,但我碰巧也在使用豆荚。

Basically you get an error, click on it and try to modify the file to fix the error and sometimes, not sure how, Xcode produces this error.

基本上你会得到一个错误,点击它并尝试修改文件来修复错误,有时,不知道是如何,Xcode 产生这个错误。

Since Xcode is stuck trying to save the changes to the file, you have to undo any changes you're made to the file in the error browser. Then editing the file by clicking on it in the regular browser instead of the warning/error pane will let you modify the file and save it.

由于 Xcode 无法保存对文件的更改,因此您必须在错误浏览器中撤消对文件所做的任何更改。然后通过在常规浏览器中单击文件而不是警告/错误窗格来编辑文件,您可以修改文件并保存它。

I'm running Xcode 6.1.1 and Cocoapods 0.36.0.rc.1 and this happens when trying to modify a file from a pod added as a development pod (i.e. from a local directory).

我正在运行 Xcode 6.1.1 和 Cocoapods 0.36.0.rc.1,当尝试从添加为开发 pod(即从本地目录)的 pod 中修改文件时会发生这种情况。

回答by PANKAJ VERMA

I was facing this problem while I was developing objective-c pod and one of the file(say xx.h &.m) in Classes folder was giving this error prompt. I did following approach:

我在开发 Objective-c pod 时遇到了这个问题,并且 Classes 文件夹中的一个文件(比如 xx.h &.m)给出了这个错误提示。我做了以下方法:

  1. I copiedxx(.h&.m) some where else (say Desktop)
  2. Deletexx(.h&.m) completely from classes folder .
  3. Force quitXcode
  4. Reopenthe project
  5. Dragthe file xx(.h&.m) . Select 'copy item if needed' and 'target'.
  1. 复制了xx(.h&.m) 其他地方(比如桌面)
  2. 从 classes 文件夹中完全删除xx(.h&.m) 。
  3. 强制退出Xcode
  4. 重新打开项目
  5. 拖动文件 xx(.h&.m) 。选择“需要时复制项目”和“目标”。

problem solved!

问题解决了!

回答by Kiran K

I have face this issue many times. I followed below steps to fixed this.

我已经多次面临这个问题。我按照以下步骤解决了这个问题。

  1. Select file->Show in Finder
  2. Copy the file and paste it in a different location.
  3. Remove the original file from Xcode by selecting show in finder
  4. Re-add the file that you copied from a destination and drag it into Xcode file pane where it was before.
  5. Clean and run the code.
  1. 选择文件->在 Finder 中显示
  2. 复制文件并将其粘贴到其他位置。
  3. 通过选择在 finder 中显示从 Xcode 中删除原始文件
  4. 重新添加您从目标位置复制的文件,并将其拖到之前所在的 Xcode 文件窗格中。
  5. 清理并运行代码。

回答by ElonChan

I'm running Xcode 7.3 and CocoaPods 1.0.0. and this happens when trying to modify a file from a pod added as a development pod (i.e. from a local directory).

我正在运行 Xcode 7.3 和 CocoaPods 1.0.0。当尝试从添加为开发 pod(即从本地目录)的 pod 中修改文件时会发生这种情况。

I just pod update again, when pod finished, Xcode will show an alert "The document has previously unsaved changes.", then click "Re-Save". that fix my issue.

我只是再次 pod 更新,当 pod 完成时,Xcode 会显示一个警告“文档之前有未保存的更改。”,然后单击“重新保存”。这解决了我的问题。

回答by Zgpeace

delete the generated pod folder, pod install again. solve my problem

删除生成的pod文件夹,重新安装pod。解决我的问题

回答by Amr

For me what worked was restarting the Macbook.

对我来说,有效的是重新启动 Macbook。

回答by Godfather

Delete derived data. Force quit Xcode. Open Xcode Done

删除派生数据。强制退出 Xcode。打开 Xcode 完成

回答by Vivek

I also had the same problem , it was when i was moving the file from one group to another . Xcode showed the same pop-up . All i did was copied all the content of the file with to a new file and deleted the old file , then quit and open the Xcode which solved the problem finally .

我也遇到了同样的问题,当我将文件从一组移动到另一组时。Xcode 显示相同的弹出窗口。我所做的只是将文件的所有内容复制到一个新文件中并删除旧文件,然后退出并打开 Xcode 最终解决了问题。