xcode 无法保存文档“...”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4089450/
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-09 03:35:03  来源:igfitidea点击:

xcode The document "..." could not be saved

xcodesave

提问by thomdask

I use xcode 3.2.4 on snow leopard. Today when I tried to save a file on my project I get an error message saying: The document "nameOfFile.m" could not be saved. I tried reinstalling xcode but no luck. The file can be edited with other editors and I see the same behavior on all my projects as well as newly created projects. Any ideas?

我在雪豹上使用 xcode 3.2.4。今天,当我尝试在我的项目中保存文件时,我收到一条错误消息:无法保存文档“nameOfFile.m”。我尝试重新安装 xcode 但没有运气。该文件可以使用其他编辑器进行编辑,我在所有项目以及新创建的项目中都看到了相同的行为。有任何想法吗?

Screenshot for error warning

错误警告的屏幕截图

回答by thomdask

Simply by rebooting the computer the issue was fixed.

只需重新启动计算机即可解决问题。

回答by Wayne Cochran

We were having this problem in a lab environment where user files are mounted via NFS. The client machines are running OS X 10.6.7 and the file server is running Debian Linux. After much grief and reading /var/log/syslog on the client machine I discovered it was a subtle file locking / race condition issue with the file system. Evidently, when editing files in a "bundle" (e.g. as in an Xcode project), the OS is using some form of "safe writes" which involves writing transient data atomically to ~/Library/Caches/TemporaryItems/ (which of course is on the NFS mounted system) -- there is a race here that requires proper file locking. We hope we have fixed the problem by changing the nfs_mount options as described in Mounting NFS volumes in OS X

我们在通过 NFS 挂载用户文件的实验室环境中遇到了这个问题。客户端机器运行 OS X 10.6.7,文件服务器运行 Debian Linux。在经历了很多痛苦并在客户端机器上阅读 /var/log/syslog 之后,我发现这是文件系统的一个微妙的文件锁定/竞争条件问题。显然,在“捆绑”中编辑文件(例如在 Xcode 项目中)时,操作系统正在使用某种形式的“安全写入”,这涉及将瞬态数据原子地写入 ~/Library/Caches/TemporaryItems/(当然是在 NFS 挂载系统上)——这里有一场比赛,需要正确的文件锁定。我们希望通过更改 nfs_mount 选项来解决问题,如在 OS X挂载 NFS 卷中所述

回答by voodoogiant

Make sure you have you mouse focused on the code area and not the file in the file list.

确保将鼠标放在代码区域而不是文件列表中的文件上。

回答by Kevin M.

Not sure why but the temp files ended in a odd state. In "/private/var/folders" I simply removed all the folders and it cleared up the problem

不知道为什么,但临时文件以奇怪的状态结束。在“/private/var/folders”中,我简单地删除了所有文件夹并解决了问题

cd /private/var/folders

sudo rm -fR *

Note: never do a "sudo rm" unless you really know what you are doing. It can cause irrecoverable damage

注意:除非您真的知道自己在做什么,否则永远不要执行“sudo rm”。可能造成无法挽回的损失

回答by Adam Eisfeld

Cleaning the project (Product > Clean), then force quitting Xcode (Command + Option + Escape, select Xcode, click Force Quit) solved the issue for me. I'm not sure if the clean was necessary, but that was what I did. Upon re-opening the project, I let Xcode index the project before doing anything, then did a Build, and all is well.

清理项目(产品 > 清理),然后强制退出 Xcode(Command + Option + Escape,选择 Xcode,单击强制退出)为我解决了这个问题。我不确定是否需要清洁,但这就是我所做的。重新打开项目后,我让 Xcode 在做任何事情之前为项目建立索引,然后进行构建,一切都很好。

回答by bharath gangupalli

Hey........... even i faced the same problem..... But got the answer...... steps:

嘿.......即使我也面临同样的问题......但得到了答案......步骤:

  1. reveal in folder the project.
  2. select the file that is locked
  3. select 'GEt Info'
  4. deselect ie uncheck the label 'LOCKED' in the Info.
  1. 在文件夹中显示项目。
  2. 选择被锁定的文件
  3. 选择“获取信息”
  4. 取消选择即取消选中信息中的标签“锁定”。

回答by Martin

I just ran into the same problem, then I noticed I ran out of disk space. You can disable the warning that pops up when you run low on disk space (perhaps not a wise thing to do). I did that a few days ago and was puzzled for a moment when this message appeared. They could've just said "Disk full" or something instead of "cannot save". Anyway if anyone ever runs into this just free up some disk space.

我刚刚遇到了同样的问题,然后我注意到我的磁盘空间不足。您可以禁用在磁盘空间不足时弹出的警告(这可能不是明智之举)。几天前我这样做了,当这条消息出现时,我感到困惑了一会儿。他们可以只说“磁盘已满”或其他什么而不是“无法保存”。无论如何,如果有人遇到这个问题,请释放一些磁盘空间。

You might be able to save in an external editor because its not also building your app which might use up the little remaining space. It might also be why it worked after rebooting (if OS X cleaned up some cached stuff on reboot) so it seems plausible.

您可能可以保存在外部编辑器中,因为它不会同时构建您的应用程序,而这可能会耗尽剩余空间。这也可能是它在重新启动后工作的原因(如果 OS X 在重新启动时清理了一些缓存的东西),所以它似乎是合理的。

Either that or your HDD might have just crashed. tic....tic....tic.....

或者你的硬盘可能刚刚崩溃。抽……抽……抽……

回答by UmairBhatti

In my Case, the File which was saying document could not be saved was basically Shortcut/Allies of the file present at another place.

在我的案例中,说文件无法保存的文件基本上是另一个地方存在的文件的快捷方式/盟友。

I don't know why it was not able to save if it was opened by shortcut/allies in xcode but by overwriting(Copy and Paste) the orignal files to that shortcut my problem was solved.

我不知道为什么它无法保存,如果它是由 xcode 中的快捷方式/盟友打开的,但是通过覆盖(复制和粘贴)该快捷方式的原始文件,我的问题得到了解决。

Regards Umair Bhatti

问候乌梅尔·巴蒂

回答by Rakhyas 3embed

1.Right click on that file 2.Go to Show in Finder . 3.Click on get info . 4.Goto Sharing & Permission

1.右键单击该文件 2.转到在 Finder 中显示。3.点击获取信息。4.Goto共享和许可

Everyone,username,Fetching & selection ----You can choose appropriate read write option.

每个人,用户名,获取和选择----您可以选择合适的读写选项。

回答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 those file and past different destination.
3. Remove those file from xCode (to selecting show in finder)
4. Then again add those files from other destination to actual location 
5. Clean code and run the code.