无法在 Xcode 4 中解锁文件进行编辑?

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

Unable to unlock file for editing in Xcode 4?

xcode

提问by Ngoan Nguyen

For some reason 2 of my files got locked and when I click the little lock icon in the upper right corner of the window it asks me if I would like to unlock, and doing so results in a "The file xxxx.h could not be unlocked" (Unlocking failed for an unknown reason). I have tried to restart Xcode, also tried to restart my machine with no help.

由于某种原因,我的 2 个文件被锁定,当我单击窗口右上角的小锁图标时,它询问我是否要解锁,这样做会导致“文件 xxxx.h 无法解锁”(解锁因未知原因失败)。我尝试重新启动 Xcode,也尝试在没有帮助的情况下重新启动我的机器。

I am also unable to edit the files using BBEdit, I get the error "You do not have sufficient privileges to perform this operation (MacOS Error code: -5000)".

我也无法使用 BBEdit 编辑文件,出现错误“您没有足够的权限来执行此操作(MacOS 错误代码:-5000)”。

I'm running OS X Lion with Xcode 4.

我正在使用 Xcode 4 运行 OS X Lion。

Very strange as I have not made any changes to my system prior to this problem. Any help would be appreciated.

很奇怪,因为在出​​现此问题之前我没有对我的系统进行任何更改。任何帮助,将不胜感激。

回答by eecue

What you're dealing with here is an ACL issue. If you ls -l the directory you'll see a little + on the end of the permission string:

您在这里处理的是 ACL 问题。如果您 ls -l 目录,您将在权限字符串的末尾看到一个小 +:

drwxr-xr-x+ 4 eekyou  staff  136 May  6  2011 eekyou.xcuserdatad

You can easily strip these off like so (in your project directory:

您可以像这样轻松地剥离这些(在您的项目目录中:

sudo chmod -R -E ./*

Hope this helps.

希望这可以帮助。

=]

=]

回答by Peter Kazazes

Open the file in any text editor. If the contents isn't text based you'll see a lot of gibberish. Ignore this, copy the contents. Open up a new text file. Paste the contents and save over the old file. This will copy just the contents of the file and ignore permissions.

在任何文本编辑器中打开文件。如果内容不是基于文本的,您会看到很多乱码。忽略这一点,复制内容。打开一个新的文本文件。粘贴内容并保存在旧文件上。这将仅复制文件的内容并忽略权限。

回答by etolstoy

The @eecueanswer didn't help me. I user another Terminal command for complete removal of all ACL permissions:

@eecue回答对我没有帮助。我使用另一个终端命令来完全删除所有 ACL 权限:

sudo chmod -RN ./*

须藤 chmod -RN ./*

回答by StijnSpijker

First check if the file is opened/locked by another program or user.

首先检查文件是否被另一个程序或用户打开/锁定。

If it is not, the program probably crashed and failed to remove the flag, lookup the file and check with CMD+i if it is locked.

如果不是,则程序可能崩溃并且无法删除标志,查找文件并使用 CMD+i 检查它是否被锁定。

If it is not, permissions are probably wrong, so check the permission in the CMD+i dialog at the bottom, and apply them to everything in the enclosing folder (a .xcproject is a directory).

如果不是,则权限可能有误,因此请检查底部 CMD+i 对话框中的权限,并将它们应用于封闭文件夹中的所有内容(.xcproject 是一个目录)。

If this stilldoesn't work (like for me), there is a simple command line to unlock all files in a folder. ONLY do this if all the above steps have been checked / taken.

如果这仍然不起作用(就像我一样),有一个简单的命令行可以解锁文件夹中的所有文件。只有在检查/采取了上述所有步骤后才执行此操作。

sudo chflags -R nouchg /Users/username/Development/GIT/MyProject

Replacing the project folder with your own project folder of course.

当然,用您自己的项目文件夹替换项目文件夹。

回答by StijnSpijker

You may need to take ownership of the folder in which you wish to save your project. To do so, open up the console. Then type sudo chown $USER /path/to/your/project.

您可能需要拥有要保存项目的文件夹的所有权。为此,请打开控制台。然后键入sudo chown $USER /path/to/your/project