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

Rebooting fixed the error in my case.


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.

Xcode 6 update: still seeing this problem.

Seems like an Xcode bug, because opening the file by clicking the error in the Issue navigator causes this problem, but if I open the file using the cmd+shift+O shortcut I am able to edit and save it. So for me the workaround is to not open the file by selecting the error and to open it using the Project navigator or Open quickly shortcut.