I have an issue that I can only assume is with Xcode, where my apps take forever to run and crash the phone/restart about 75% of the time. I tried using older versions of the code that I'd saved instead, but they had the same effect, which they didn't use to have about a month ago.
I've looked up every single possible way to solve this issue for the past few weeks have haven't found anything, so I want to completely uninstall Xcode and clear all settings; but I can't find a way to do this. I can uninstall it, but when I reinstall it, it still has all of my old settings and lists of projects etc. How can I completely uninstall it?
For complete removal old Xcode 7 you should remove
/Applications/Xcode.app
/Library/Preferences/com.apple.dt.Xcode.plist
~/Library/Preferences/com.apple.dt.Xcode.plist
~/Library/Caches/com.apple.dt.Xcode
~/Library/Application Support/Xcode
~/Library/Developer/Xcode
~/Library/Developer/CoreSimulator
For a complete removal of Xcode 10 delete the following:
/Applications/Xcode.app
~/Library/Caches/com.apple.dt.Xcode
~/Library/Developer
~/Library/MobileDevice
~/Library/Preferences/com.apple.dt.Xcode.plist
/Library/Preferences/com.apple.dt.Xcode.plist
/System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.bom
/System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.plist
/System/Library/Receipts/com.apple.pkg.XcodeSystemResources.bom
/System/Library/Receipts/com.apple.pkg.XcodeSystemResources.plist
/private/var/db/receipts/com.apple.pkg.Xcode.bom
But instead of 11, open up /private/var/in the Finder and search for "Xcode" to see all the 'dna' left behind... and selectively clean that out too. I would post the pathnames but they will include randomized folder names which will not be the same from my Mac to yours.
but if you don't want to lose all of your customizations, consider saving these files or folders before deleting anything:
~/Library/Developer/Xcode/UserData/CodeSnippets
~/Library/Developer/Xcode/UserData/FontAndColorThemes
~/Library/Developer/Xcode/UserData/KeyBindings
~/Library/Developer/Xcode/Templates
~/Library/Preferences/com.apple.dt.Xcode.plist
~/Library/MobileDevice/Provisioning Profiles
Open Storage Management
Go to > About This Mac > Window > Storage Management
Or, hit ⌘ + Space to open Spotlight and search for Storage Management.
Select Applications on left pane.
Right click on Xcode on the right pane and select delete.
This will remove XCode from the installed applications list of your Mac's App Store.
Update: This worked for me on macOS Sierra 10.12.1.
Before taking such drastic measures, quit Xcode and follow all the instructions here for cleaning out the caches:
How to Empty Caches and Clean All Targets Xcode 4
If that doesn't help, and you decide you really need a clean installation of Xcode, then, in addition to all of the stuff in that answer, trash the Xcode app itself, plus trash your ~/Library/Developer folder and your ~/Library/Preferences/com.apple.dt.Xcode.plist file. I think that should just about do it.
FOR UNINSTALLING AND THEN BEING ABLE TO REINSTALL XCODE 9 CORRECTLY
I followed the topmost answer for deleting Xcode 7 and found a major error, deleting ~/Library/Developer will delete an important folder called PrivateFrameworks, which will actually crash Xcode everytime you reinstall and force you to have to get your friends to send you the PrivateFrameworks folder again, a complete waste of time seeing if you needed to uninstall and reinstall Xcode urgently for immediate work purposes.
I have tried editing the topmost answer but see no changes so below is the modified steps you should take for Xcode 9:
Delete
/Applications/Xcode.app
~/Library/Preferences/com.apple.dt.* (Generally anything with com.apple.dt. as prefix is removable in the Preferences folder)
~/Library/Caches/com.apple.dt.Xcode
~/Library/Application Support/Xcode
Everything in
/Library/Developer directory except for
/Library/Developer/PrivateFrameworks
This answer should be more of a comment against Dawn Song's comment earlier, but since I don't have enough reputation, I'm going to write it as an answer.
According to the forum page
https://forums.developer.apple.com/thread/11313
"In general, you should never just delete the CoreSimulator/Devices directory yourself. If you really absolutely must, you need to make sure that the service is not runnign while you do that. eg:"
# Quit Xcode.app, Simulator.app, etc
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
rm -rf ~/Library/*/CoreSimulator
I definitely ran into this issue after deleting and reinstalling Xcode.
You might encounter a problem trying to connect the build to a simulator device. The thread also answers what to do in that case,
gem install snapshot
fastlane snapshot reset_simulators
Run this to find all instances of Xcode in your filesystem:
for i in find / -name Xcode -print; do echo $i; done
Related
I have a React Native project that works fine most of the time(Android and iOS). But sometimes out of nowhere I receive this error when I am trying to build the Xcode project (Xcode or react-native run-ios):
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.
How do I solve this? Push to a branch on git, fresh clone, npm install, and all is working fine for a period. And after that the problem will repeat. Making fresh clones of project each time is a pain and takes long time. Is there another way or something that I don't know?
Maybe a some files that are in .gitignore is causing the problems, and after a fresh clone that solves the problem. This is the .gitignore file for my iOS project:
# Created by .ignore support plugin (hsz.mobi)
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
I had this same issue and it was fixed by deleting the contents of node_modules and doing a npm install in the parent folder.
I was faced with this problem too. And I noticed that my folder name was too long. I changed the project folder's name with the short one and this error gone. Try to change the project folder name.
It was really a time killer issue. I rebased the complete code base to a collegue's mac where it worked fine. After sparing more than a couple of morning hours I could find a solution.
Solution - Simply shorten your Project folder name (in mac).
This is undoubtedly irritating that its suggested to have longer and meaningful variable names but the folder name has to be this concise.
I had a issue with XCode 9.1 and iOS 11...
I solved this issue moving up my folder to another path, I know it doesn't make sense and is dumb but it really work for me. My project was at /Users/Me/Documents/MyProjectDir and I changed to /Users/Me/Desktop/MyProjectDir
What helped me was removing the ios/build folder in my React Native project, followed by rebuilding the project.
I highly recommend to run the build on console, to see if it outputs any other relevant information.
react-native run-ios --scheme "app-debug" # Or any aproppriate target
Read more about building+archiving from CLI here or try with other OSS tooling like fastlane.
For me it found bugs twice, that both were unrelated with the building process itself:
1) One was fixed rolling back to node v8 (LTS) apparently. It was very obscure, but I suspect had to do with having little memory available (running flow + packager + xcode + spotify + chrome on 8GB RAM MBP)
2) The other one was related to having a space on the xcode output. "App Canary.app" could not be installed. I figured it out doing ls ios/build/Build/products.... This error only happened after upgrading xcode, and wasn't happening with the release target, that did not have any whitespaces.
The only take away here is to run build directly on the console to debug further. You might find out things that are completely unrelated, and probably can't be solved by just removing the build folder.
Hope it helps.
Trashing ios/Build resolved this issue for me
In my case simulator is not shutdown correctly.
So I opened simulator manually again then I got an error that simulator is not shutdown correctly.So I relaunched the simulator successfully and built xcode project again. Error is resolved
I have a problem I don't know why did it happen in the first place but most probably because I've pressed move to trash to some system frameworks by mistake.
I got an error that says:
malformed or corrupted AST file: 'could not find file '/Users/username/myProject/QuartzCore.framework/Headers/CAMediaTiming.h' referenced by AST file'
I've tried to copy QuartzCore.framework in that Directory. It give me then a punch of new errors. Then if I remove the framework from the Dir. Everything will be good for the project till I make any code change. Then I would have to make the previous scenario again. It's very annoying now and I really need to fix this. Anyone?
As requested:
What caused this error for me (after getting the new Xcode) was I would try to run a project in simulator (accidentally in simulator, I never use simulator), but I'd forget to select my device or my device would become unplugged without me noticing, and it will try to run in simulator... so I would get those classic ".o" file errors... Then I would switch back to my device and get corrupt AST files...
To CURE the problem... (Follow the steps below VERY closely!!!!!)
Clean your project
QUIT Xcode (CMD+Q)
Run this Terminal Command: rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache/*
Run this Terminal Command: rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/*
Reopen Xcode
MAKE SURE YOU HAVE YOUR DEVICE SELECTED AND NOT SIMULATOR
CLEAN project (Yes, again)
THEN build (to your device, not to simulator)...
Enjoy!
Note: After further experimentation I've found that the force-quitting of xCode is possibly not necessary.
In addition to all of the other "clean your build" answers, nothing was working for me until I emptied out the (highly undocumented!) /var/folders directory.
Apparently, this is a "miscellaneous caches" dir maintained by OS-X. I didn't even bother figuring out what were "the correct files"; I just cleaned out the entire directory.
...And now I can build again. Hooray! From terminal:
[sudo] rm -rf /var/folders/*
(Although I did it from Finder, via authentication.) (OS-X 10.9.latest)
Additional clue: I could build with XCode-6-beta, but got the goofy "corrupted AST file" error in XCode-5.
In my situation, all I needed to do was click Product > Clean, then build the project again. It succeeded. Hope this helps some others who run into the same situation.
Hi all I got the same error because I have opened two projects at a time and drag and dropped frameworks from one project to another .
After some time I realised that this is not a right way. I moved all frameworks which are dragged from another project to trash. Then clean and run in simulator everything is working fine.
Delete frameworks->again add frameworks->clean and run
I hope it will help someone
Personnaly, just one solution worked for me:
In Xcode Go to Window -> Organizer
Clic on the "delete" button near the "derived data" directory.
Then Run again your project...
I just clean my project and re-build. Everything back to normal.
In my case, the error was happening because I had a corrupted .m file - it was one that had, somehow (not quite sure how) found its way into my project (I had Eclipse open at the same time and the corrupted file had some java code in it). To fix the problem, I cleaned my project, closed Xcode, deleted the erroneous .m file & re-opened Xcode. It then gave me a clang error due to the now missing .m file. I created a new, empty .m file with the same name and the project ran fine. Bit of a hack but it worked :-)
I am running low on disk space and checked through a third party utility that among other things that ~/Library/Developer/Xcode/DerivedData directory is taking about 22GB of disk space.
I searched stackoverflow and found this post
How can I safely delete in my ~/Library/Developer/Xcode/DerivedData directory?
The accepted answer to this question suggests that I should not touch / remove folders from this directory. so what I did was
Found an existing build project folder for an app that I have available on Appstore
Deleted the folder from derived dir
launched XCode 5
Open that project
Clean Build
Tested and compiled it on a simulator
ReArchived
Everything worked. Nothing was broken.
Unless I missed something in that posts answer I want to make sure by asking experienced developers that if I delete all the folders from DerivedData it will not hurt me in building, testing and compiling those projects.
Yes, you can delete all files from DerivedData sub-folder (Not DerivedData Folder) directly.
That will not affect your project work. Contents of DerivedData folder is generated during the build time and you can delete them if you want. It's not an issue.
The contents of DerivedData will be recreated when you build your projects again.
Xcode8+ Update
From the Xcode8 that removed project option from the window tab so you can still use first way:
Xcode -> Preferences -> location -> click on small arrow button as i explain in my first answer.
Xcode7.3 Update
For remove particular project's DeriveData you just need to follow the following steps:
Go to Window -> Project:
You can find the list of project and you can either go the DerivedData Folder or you can direct delete individual Project's DerivedData
I am not working on Xcode5 but in 4.6.3 you can find DerivedData folder as found in the below image:
After clicking on Preferences..
You get this window
I purge derivedData often enough that I have an alias for it. It can fix build problems. I have the following in /Users/Myusername/.bash_profile
alias purgeallbuilds='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
Then in terminal, I type purgeallbuilds, and all subfolders of DerivedData are deleted.
XCODE 12 UPDATE
On the tab:
Click Xcode
Preferences
Locations -> Derived Data
You can access all derived data and clear by deleting them.
XCODE 7.2 UPDATE
(Also works for 7.1.1)
Click Window then Projects and then delete Derived Data.
Like this:
And then delete it here:
Hope that helps!
$ du -h -d=1 ~/Library/Developer/Xcode/*
shows at least two folders are huge:
1.5G /Users/horace/Library/Developer/Xcode/DerivedData
9.4G /Users/horace/Library/Developer/Xcode/iOS DeviceSupport
Feel free to remove stuff in the folders:
rm -rf ~/Library/Developer/Xcode/DerivedData/*
and some in:
open ~/Library/Developer/Xcode/iOS\ DeviceSupport/
Just created a github repo with a small script, that creates a RAM disk. If you point your DerivedData folder to /Volumes/ramdisk, after ejecting disk all files will be gone.
It speeds up compiling, also eliminates this problem
xc-launch repo
Best launched using DTerm
XCode 8: To delete derived data for your current project:
Click Product menu
Hold Option key
Click Clean Build Folder
XCODE 10 UPDATE
Click to Xcode at the Status Bar
Then Select Preferences
In the PopUp Window Choose Locations before the last Segment
You can reach Derived Data folder with small right icon
~/Library/Developer/Xcode/DerivedData
yes, safe to delete, my script searches and nukes every instance it finds, easily modified to a local directory
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'
for drive in Swap Media OSX_10.11.6/$HOME
do
pushd /Volumes/${drive} &> /dev/null
gfind . -depth -name 'DerivedData'|xargs -I '{}' /bin/rm -fR '{}'
popd &> /dev/null
done
I would say it's safe--I often delete the contents of the folder for many kind of iOS projects, this way. And, I haven't had any issues with builds or submitting to the App Store. The procedure deletes derived data and cleans a project's cached assets, for both Xcode 5 and 6.
Sometimes, simply calling rm -rf on the Derived Data directory leaves a lingering file or two, but my script loops until all files are deleted.
The content of 'Derived Data' is generated during Build-time. You can delete it safely. Follow below steps for deleting 'Derived Data' :
Select Xcode -> Preferences..
This will open pop-up window. Select 'Locations' tab.
In Locations sub-tab you can see 'Derived Data'
Click on arrow icon next to path.
This will open-up folder containing 'Derived Data'
Right click and Delete folder.
I removed an older version of Xcode following the instructions in How to fully remove Xcode 4 and then installed version 4.3 from AppStore. But now /developer directory is missing.
I can find the same directory structure in /applications/xcode.app/contents/Developer/. Is /developer just a link to that directory and how can I create it again?
According to the XCode 4.3 release notes, the /developer directory is no longer needed.
/Developer No Longer Exists
The simplification afforded by repackaging
Xcode 4.3 as a single app bundle eliminates the need for the
/Developer directory containing prior versions of Xcode. As a result,
the Install Xcode application and the uninstall-devtools command line
script are also no longer needed.
The /Developer directory is no longer used by Xcode as jonkroll noted.
If you are looking for command line tools, you can install them using the Components tab of the Downloads preferences panel.
Yes you're right, now /Developer directory is embedded into XCode.app. So you have to make an alias to this new directory or change your path to this new folder.
One easy way to get to it is to right click on an existing framework that you have imported in your project; then choose "open in finder". Then you can hit option + the up arrow key on your key board to traverse up to the developer folder (e.g if you want to peruse the contents of your simulator documents folder etc...) & make a short cut to it for direct navigation..
Switching directories worked for me:
sudo xcode-select -switch /
I have several projects that with the upgrade to Xcode 4.3 don't crash but don't load their views either. Since it's a widespread problem, I wonder if I need to remake all the connections in the nib or some other global sort of change? I hope I didn't move to 4.3 too soon! Thanks
Amateur Hour: After upgrading to Xcode 4.3, my projects for some reason started opening with Xcode 3.2 Back to work!
I had a similar problem with Xcode 4.3; App windows were not loading after clean compiles. I found an apparent (so far) fix/workaround by deleting the failing app's folder within this folder:
~/Library/Saved Application State/.
In Terminal:
cd ~/Library/Saved\ Application\ State
(note the backslashes "\") Then delete the folder for the failing app:
rm -fr pgmname.savedState/
Or rename it:
mv pgmname.savedState/ z-pgmname.savedState/
Or maybe you can just rename it or trash it from Finder (I can't for some reason).