Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode: "The document could not be saved. You don’t have permission."

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."

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?

Thanks.

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).

Update 2: Found possible duplicate, doesn't really resolve the problem Unable to unlock file for editing in Xcode 4?

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.

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.)

like image 864
Michael Avatar asked Nov 08 '11 13:11

Michael


2 Answers

Rebooting fixed the error in my case.

like image 56
HansPinckaers Avatar answered Sep 19 '22 13:09

HansPinckaers


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.

(From above link:)

For Mac OS X v10.5 or later (do this twice if you want to keep your original username) :

  1. Enable the root user.
  2. Log in as root.
  3. Navigate to the /Users folder.
  4. 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.
  5. 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.
  6. 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.
  7. Choose Log Out from the Apple menu.
  8. 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).
  9. 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).
  10. Disable the root user.
like image 23
Michael Avatar answered Sep 19 '22 13:09

Michael