问题描述
尝试在Xcode 4中保存文件时出现此错误:无法保存文档.您没有权限.要查看或更改权限,请在Finder中选择项目,然后选择文件">获取信息"."
I'm getting this error when trying to save a file in Xcode 4:"The document could not be saved. You don’t have permission. To view or change permissions, select the item in the Finder and choose File > Get Info."
自然,将文件保存在TextMate中可以正常工作.权限:-rw-r--r-
Naturally, saving the file in TextMate works fine. Permissions: -rw-r--r--
自上次工作以来什么都没有改变.文件未锁定,我尝试重新启动,磁盘空间正常,文件在本地驱动器上,搜索到错误.有什么想法吗?
Nothing changed from when it worked the last time.Files are not locked, I tried rebooting, disk space is ok, files are on a local drive, error was googled. Any ideas?
谢谢.
更新:还尝试了复制文件或重命名它们.目录未锁定.顺便说一句,当我在Xcode中编辑项目配置时,它保存得很好,我只遇到了保存.m/.h文件的问题.我猜想可以在文件中复制实际的文本,但是我正尝试找到一种更少的硬核解决方案(bash脚本不是问题,但可能还有其他问题).这也不是最简单的项目(〜70个文件,已编辑配置).
Update: Also tried copying the files or renaming them. Directories are not locked. By the way, when I edited project configuration in Xcode it saves fine, I only met with the issue saving .m/.h files. I guess that copying the actual text in the files would work but I'm trying to find a bit less hardcore solution (bash script wouldn't be the issue but there could be other problems). It's not the simplest project either (~70 files, edited config).
更新2:发现可能的重复项,并不能真正解决问题
Update 2: Found possible duplicate, doesn't really resolve the problem Unable to unlock file for editing in Xcode 4?
更新3:检出较早的提交,并在打开Xcode时说该项目已锁定.再次签出相同的提交,并且错误不再出现(跟踪DS_Store以外的所有文件).什么.
Update 3: Checked out earlier commit and when opening Xcode it said the project is locked. Checked out the same commit again and the error does not appear again (all files exc. DS_Store are tracked). What.
更新4:我创建了一个新用户,并将chmod -R 777设置为项目目录.现在,编辑工作正常.但是我无法在我的主要帐户下使用它(我在这里拥有所有偏好).
Update 4: I created a new user and set chmod -R 777 to the project directory. Editing now works fine. However I can't get it to work under my main account (I have all my preferences here.)
推荐答案
通过遵循此更改帐户名来解决指南.此必备项创建了一个新帐户,但具有您的旧主目录,并且在转移过程中修复了一些文件权限.
Fixed by changing account name by following this guide. This essentialy creates a new account but with your old Home directory and within the process of transferring it fixes some file permissions.
(从上面的链接:)
对于Mac OS X v10.5或更高版本(如果要保留原始用户名,请重复两次):
For Mac OS X v10.5 or later (do this twice if you want to keep your original username):
- 启用root用户.
- 以root用户身份登录.
- 导航到/Users文件夹.
- 选择要更改的短名称的Home文件夹,然后重命名,就像重命名任何文件夹一样.请记住,短名称必须全部为小写字母,不能有空格,并且只能包含字母.
- 使用用户& 系统偏好设置"中的组"窗格(在Mac OS X v10.6.8或更早版本中为帐户"窗格),以使用上一步中使用的帐户名或简称来创建新用户.
- 当用户"文件夹中的文件夹已经具有名称帐户名称"时,单击确定".是否要将该文件夹用作该用户帐户的主文件夹?"注意:这将更正主文件夹中所有文件的所有权,并避免内容出现权限问题.
- 从Apple菜单中选择注销".
- 以新创建的用户身份登录.您应该能够访问所有原始文件(在桌面,文档以及此主页的其他文件夹中).
- 在确认您的数据符合预期之后,您可以通过用户和用户"删除原始用户帐户. 组"窗格(Mac OS X v10.6.8或更早版本中的帐户"窗格).
- 禁用root用户.
- Enable the root user.
- Log in as root.
- Navigate to the /Users folder.
- Select the Home folder with the short name you want to change, and rename it just like you would rename any folder. Keep in mind that the shortname must be all lowercase, with no spaces, and only contain letters.
- Use the Users & Groups pane (Accounts pane in Mac OS X v10.6.8 or earlier) in System Preferences to create a new user with the Account name or Short Name that you used in the previous step.
- Click OK when "A folder in the Users folder already has the name 'account name'. Would you like to use that folder as the Home folder for this user account?" Note: This will correct the ownership of all files in the Home folder, and avoid permissions issues with the contents.
- Choose Log Out from the Apple menu.
- Log in as the newly created user. You should be able to access all of your original files (on the desktop, in Documents, and in the other folders of this Home).
- After verifying that your data is as expected, you can delete the original user account via the Users & Groups pane (Accounts pane in Mac OS X v10.6.8 or earlier).
- Disable the root user.
这篇关于Xcode:“该文档无法保存.您没有权限."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!