Can't save any files in Xcode due to permission error - xcode

I suddenly can't save any files in any of my Xcode projects in my home directory. Not sure what caused this. Here's the error I'm receiving:
I don't think Xcode is correct, since I am the owner of -- and have read+write permissions on -- the affected files.
A few other fun facts:
I can edit these files in other applications as the same user, so the problem seems to be specific to Xcode.
Other users can create and edit projects in their home directory without issue.
Running Xcode as root (via sudo /Developer/Applications/Xcode.app/Contents/MacOS/Xcode) does allow me to edit these files.
chown, chmod -R 755, etc. on the directory containing my projects doesn't help.
Disk Utility > Repair Permissions doesn't help.
Reinstalling Xcode, clearing Xcode .plists, etc. doesn't help. Failing both on Xcode 4.1 and 4.2.
Thoughts? Hopefully I'm just missing something simple.

I've just run into this issue myself. No amount of rebooting fixed it for me. In fact, it only began after a reboot. After much frustration, I used fs_usage to observer the file system calls that Xcode and any other processes were making when I attempted to save.
The results were interesting. In particular, one of the last things I saw before Xcode loaded NSAlertPanel.nib (which I assume is the UI for the error sheet), thing showed up:
revisiond.3029 getattrlist /private/var/folders/9f/_7xjwv310nb6c7yr6py_9jtc0000gn/T/TemporaryItems
Xcode.2437 mkdir /private/var/folders/9f/_7xjwv310nb6c7yr6py_9jtc0000gn/T/TemporaryItems/(A Document Being Saved By Xcode)
This looked highly suspect to me, so I investigated this directory. It turns out that
"/private/var/folders/9f/_7xjwv310nb6c7yr6py_9jtc0000gn/T/TemporaryItems" was owned by root:staff, and NOT writable by the group. Making this directory writable by the group fixed the issue for me immediately.
So, it appears this was a bad iteration between Xcode and revisiond, which is responsible for the File Coordination features in Lion. I do not know why this problem persisted for me when a reboot fixed it for others.

Check how you have this setup in source control. I've noticed with the new Xcode that if you have this under source control (svn) that that might be blocking your ability to write over the file regardless of permissions.
You may want to do an svn cleanup

from terminal issue a
ls -laE#"
There may be extended attributes or ACL (Access Control List) permissions problems. I have had that happen. It can be really bad if it has inherited attributes
If that is the case fix with
chmod -R -N
Be careful!

Looks like I had netbiosd blocked in my firewall configuration. After unblocking it and restarting my computer, the issue seems to be resolved.

I spent about two hours with this same problem. I tried all of the above. Finally, I rebooted my machine. Everything works fine after the reboot.

Everything was working fine and i ran into this issue. I tried most of the above suggestion. Finally,the MacOSX software update resolved the issue.

Related

Can't install kext, "Read-only file system"

So, I've been racking my brain against the wall for the last 6 hours trying to get this to work and I'm still at a loss..
I'm trying to install a kext on Big Sur from this repo, https://github.com/SimulPiscator/vpcm, and when I try and move the compiled kext to /System/Library/Extensions I keep getting 'Read-only file system' error..
I have disabled SIP
Tried enabling root user
Added myself to the 'wheel' group
Reduced security level in security utility
Tried changing permissions on the /System dir, keeps telling me I don't have permission.
I feel like I'm missing something obvious... Every article I've seen online tells me to put the kext in that directory and run kextload.. But how the heck do I get write permissions to that directory??
So, I'm not sure if this is what is supposed to happen or not, but placing the kext in /Library/Extensions instead of /System/Library/Extensions worked.
I'm not sure if this is the correct thing to do but since it works, I'm not complaining.

Xcode error "The file MyApp couldn't be opened because you don't have permission to view it" after switching to a new computer

Just switched to a new MacBook after my old one got a logic board issue and died. I transferred some apps over from an external hard drive, and none of them will run-- I just get the error in the title.
This has been addressed before, but none of the solutions have worked. I've tried:
Manually setting file permissions
Cleaning the project multiple times
Setting the compiler for C/C++/Obj C to default
Restarting my computer
Replacing my info.plist file with a clean one
Deleting derived data
Checked my architecture settings are accurate
Some other solutions I've found on here (deleting folders that code was moved into, etc) aren't applicable
Worth noting that in addition to switching computers I upgraded Xcode to the latest version (my version on the previous computer was about a year old).
Does anyone have any other thoughts? I'm stuck and have no idea what else to try.
Try change permissions recursively. Go to terminal, open folder with your project and write:
sudo chown -R $USER .

Cannot delete files, permissions are messed up (Windows 7)

What I did
I just started using git, and I think I accidentally initialized a bare repository (instead of a normal one) in my www folder. So when I committed everything, I noticed it started removing everything, which I didn't expect at the time. That's where I made the mistake of killing git. Now there's two files that I can't delete/move/read/write/execute.
When I knew what git was actually doing, I then cloned the git repo in my www folder to my desktop, and it looks like I got most of it back, including those two files, which are normal, and I can write and read to them.
What I'm trying to accomplish
I realize that this may seem like an elaborate scheme to learn how to hack, but that's not the case, I own these files and my goal is to delete them, not break in. I'm unable to delete them however, as killing git seems to have messed up the permissions on the file. I really desperately need to know how to delete them, otherwise git and every backup system I use keep breaking on doing anything in this directory!
Further info:
I'm using Windows 7 Ultimate x64, and Git version 1.8.5.2.msysgit.0
Below a screenshot of the situation:
When I look at the permissions tab in the file properties, I get the message I have to have be an administrative user with permissions to view its security properties. I then clicked on continue, as I have administrative permissions (since it's my laptop). In the newly opened window I get the message I don't have permission to view its security properties. When I try setting its owner, as it suggests, I get the message "Unable to set new owner on [file]. Access denied".
I already tried using an elevated command prompt to try removing them, even forcefully.
I'm desperate, guys (and girls)!
Ok, so I wasn't able to delete the files, on Windows.. I finally did it using a linux (debian 6.whatever) live-cd, and using rm -rf logs/
So if anyone else should encounter the same thing, this is a relatively quick solution.

Xcode fails without specifying and errors

All of a sudden my project fails to build in Xcode. If I look at the log I see all the needed dependencies being built, and then I get a strange error:
Verify final result code for the complete build operation
Build operation failed without specifying any errors.
Individual build tasks may have failed for unknown reasons.
I removed my code directory and replaced it with a backup, did a clean, tried building all the other components separately (they succeed) - nothing works. I tried a command line build, same issue.
There were only a few hits on google for this error, none offered any useful advice.
Can anyone please help?
Update: When I run the command line build, I see the following error:
2012-05-25 08:55:53.830 xcodebuild[3358:4203] No recorder, buildTask: <Xcode3BuildTask: 0x400f35e60:'ProcessPCH MyProject-Prefix.pch':REfc(32370056113422336):deps=0:phaseNum=4>
I checked the output of xcodebuild and it is returning '65'.
I thought there might be a problem with the MyProject-Previx.pch file, so I shut off "Precompile Prefix Header", and now I get the same error with a different file:
2012-05-25 09:15:11.784 xcodebuild[3882:3703] No recorder, buildTask: <Xcode3BuildTask: 0x40048ab60:'CompileC HelperRoutines.m':REfc(33777199068741632):deps=0:phaseNum=4>
Build operation failed without specifying any errors. Individual build
tasks may have failed for unknown reasons. One possible cause is if
there are too many (possibly zombie) processes; in this case,
rebooting may fix the problem. Some individual build task failures (up
to 12) may be listed below.
I've run into this problem consistently recently while running Xcode 9.0 Beta 3 and Xcode 8.3.3.
The fix is to delete ALL in the Derived Data folder. It then seems to work again.
rm -rf ~/Library/Developer/Xcode/DerivedData
NOTE: just cleaning the build or deleting the current build folder for a project does not seem to help.
Hope this helps :)
I was hitting this error and it infuriated me for an hour or so. The answer below helped me out a lot: essentially your machine has a ton of running processes, XCode can't handle it, and rebooting your machine is the best answer.
https://stackoverflow.com/a/13183522/1863655
I looked around for a bit and the only one that worked for me was shortening my project folder name.
All other tries: restarting, recloning, deleting derived data, etc. didn't work. The only thing that worked was making the project folder name shorter.
I also encountered same error. I was edited .pch (Prefix Header) file. Then I started getting this strange error.
Then I removed all editions which I made in .PCH.
Then I quit my Xcode.
When I restarted Xcode this strange error was gone.
Hope this will work for you also.
Best luck Buddy (y)
Build operation failed without specifying any errors. Individual build tasks may have failed for unknown reasons.
One possible cause is if there are too many (possibly zombie) processes; in this case, rebooting may fix the problem.
Some individual build task failures (up to 12) may be listed below.
This happens occur when the total path length is too long.
change the folder name or location of directory, shorter then before.
Happy 2019, everyone, but sad to say this can still happen in Xcode 10.2.
I had four projects open in Xcode but only one failed in this way. I tried a main menu > Product > Clean Build Folder. The little progress spinner started up and 5 minutes later was still spinning. Hmmmm.
So I quit Xcode and in Terminal did a cd ~/Library/Developer/Xcode/DerivedData. Although ls -alww showed only one subfolder named after each of my other projects, as expected, there were five subfolders whose name began with the name of the problem project. I deleted all of them
rm -R ProblemProjectName-*
and relaunched Xcode. Problem solved.
Mine gave this error sometimes, also LLVM failed with exit code 1 and clang failed with exit code 255, at different code locations each time. I just had to reboot (OS X 10.7, Xcode 4.5).
I rebooted, no luck. Then I noticed that when I relaunched XCode, one of my tabs was loaded with no file in it. I figured out what file I was editing in it, opened it, saved it and then I was able to build.
None of these answers worked for me on XCode 5.
Luckily, I'm still only testing XCode 5 - I kept XCode 4 around.
XCode 5 simply won't build one of my two projects, claiming that my libraries aren't built with the right settings, and I keep running into the error described on this page on the other one... so I'm sticking with XCode 4, which builds both of my projects perfectly well.
If you are experiencing this issue on XCode 5, consider "reverting to XCode 4" as another strategy.
Overall the idea that repeatedly running a program, XCode or not, degrades your system to the point where you have to reboot does not fill me with confidence in that program.
With Xcode 5.0.0, this error was caused after an update to the CLI tools.
Updating to Xcode 5.0.1 and installing all the required components again still didn't fix the error. However, 5.0.1 was kind enough to actually emit an error that was useful.
/bin/mkdir -p /Users/xxx/Documents/XCode/SampleApp/bin/SampleAppDebug.app/Contents
error: (null)
This lead me to look at the bin folder, and find out that the 5.0.0 build with broken CLI tools had made a symlink in bin/ to the derived information folder with SampleAppDebug.app, which for some reason it could not write to.
I manually removed all contents of the bin/ folder and rebuilt without errors.
I faced same problem. I have change my System time.I delete file "/Users/YOURNAME/Library/Developer/Xcode/DerivedData/ModuleCache/YOURBUNDLEID/UIKit.pcm". Then it's work fine for me. Try this.
I added into the Framework search paths the header file location.... removing this from the top level project settings fixed the issue for me.
Change at your peril.
The only workaround, that works for me - push your code to git repo and clone it to new location.
I highly recommend to reclone your repo, because you'll deal with some random problems if you prefer rebooting/turning off and onXcode.
did you set "Perform Single-Object Prelink" to Yes?
try turn it off.
i had the similar problem. i have tons of files in a static library. reducing the number of files or setting "Perform Single-Object Prelink" to NO solved my problem.
Same error and following didn't work for me for Xcode 6.3.2 on Mac OS X Yosemite 10.10.3:
Git discarded changes to last successful build point
Creation of new fresh project from scratch from a builtin template (though I cannot recall whether it built successfully or not)
Restart of Xcode
System Reboot
and the following worked:
I faced the problem in the morning and it got resolved in the evening with a couple of Xcode restarts and System reboots and creation of new project. So, I'm not sure what really triggered.
I faced the same problem today. Cleaning the DerivedData and cloning the project somewhere else didn't help. What fixed my problem was repairing the volume from the Disk Utility app and removal of all Xcode plugins.
I have encountered same issue without having any code changes for my project running on Xcode 9.2. It looks like if you have some run scripts or external build systems attached to the project, this might cause an issue. Try committing or discarding changes and build again. If it still persist, delete local repo and clone again. Also maintain smaller folder names for project location.
Same issue when added watchOS target inside iOS app, using Xcode 11.1 with SwiftUI:
Go to menu Xcode / Preferences / Locations
Open Derived Data folder in Finder clicking on the arrow next to /Users/yourUserName/Library/Developer/Xcode/DerivedData
Locate your app Derived Data folder and delete it
Menu Product / Clean Build Folder
You should be able to compile again.
I know this is super late to answer but I'm answering since none of the above solutions worked.
For me restarting, clean building, deleting derived data nothing worked.
Because the issue was not due to any zombie objects or something like that.
I'm using Xcode 11. I think it's an Xcode bug that sometimes errors are not shown in the issue navigator. But don't worry check the build report in Report navigator(The last tab in project navigator: the one that looks like a comment box with lines in it. or simply cmd + 9).
Click the relevant build and resolve the issue, mine was missing file in pods directory.
just try to rename the folder name of the project. it did the trick for me
I had this same problem, however the accepted solution did not work for me, what worked was:
deleting .workspace file
deleting Podfile.lock file
deleting the Pods folder
pod deintegrate ; pod install
For me it was fixed by changing to the new build system(in File -> Project settings)
I have Xcode 11.7

Xcode cannot save file

I am on Mac OS X 10.6.8 using Xcode 4 with Cocos2D.
The other day, I got an error message out of the blue when trying to run my project:
The document "MainMenuScene.m" could not be saved.
I tried the following, none of which has worked:
replacing the file
creating a new one and renaming it (which I could not rename it. I was told I didn't have permission)
creating a whole new project and reading the files/copy pasting the code in
opening Disk Utilities and running Repair Risk Permissions (which works again once, but then reverts back).
I sometimes get the off chance and the file does save, but reverts back to not saving again.
Anyone have any ideas on what I can do to fix this?
I had this issue with a project on an external ssd. Disconnecting the ssd and reconnecting fixed it for me.
In short:
Have you tried turning it off and on again?
See the full conversation in the comments, but this ended up being solved. Moving what was suggested/asked here for clarity and closure.
Is that the full error? Also, are you saving it on a USB or your HD?
Are you an admin on your computer, etc? Have you tried to move the project completely, or copy and try to work on it from somewhere else? With the currently given information I cant think of anything that would cause that kind of problem. What has changed since you were last able to edit and save without issues?
Glad we got it figured out!
-Karoly
Have you tried just moving the file? That'll probably do it.

Resources