Deleted Developer folder by accident in iOS 11 help me - ios

I am facing a problem. I deleted the Developer folder in the directory .
I've tried to use xcode to reinstall this folder but it keeps giving me a error
I've also tried to make the directory using sudo/root but all I get is
the error below I can create any other folder name anything else just not Developer
jamnies:/ root# sudo mkdir Developer
mkdir: cannot create directory 'Developer': Operation not permitted
jamnies:/ root# sudo mkdir Develope
jamnies:/ root#

I think the easiest solution would be to simply reinstall Xcode (though it takes a bit of time).
If you don't want to do that you could try manually reinstalling the CommandLineTools and the CoreSimulator.framework (these are the only two things that my Developer directory contains)
To do this you can find more info here:
Xcode - install Command Line Tools
How to recover from deleting Xcode CoreSimulator devices from disk?
But if I were you I would just simply reinstall Xcode.

Related

error Couldn't find "PLATFORM_NAME" variable in xcodebuild output

I'm trying to run my application on an iPhone simulator. from the console, I can see the build was successful. but on the next line, I get this.
error Couldn't find "PLATFORM_NAME" variable in xcodebuild output. Please report this issue and run your project with Xcode instead. react-native.
This is quite bizarre, but after getting this error I opened up the workspace in Xcode and ran it from there. Afterwards this error went away when running react-native run-ios
I suspect this might have something to do with the way Xcode 12 optimizes builds and that re-building it from Xcode somehow fixed it. I would like to know why, but I cbf'ed figuring it out myself.
This happened to me because I clean up some image, and removed some native dependancies. All I did was cd ios && pod install then yarn ios to build again.
Tried cleaning build folder and ran, it worked.
Xcode toolbar -> Product -> Clean build folder
Step - 1: Clean the build folder from Xcode.
Xcode toolbar -> Product -> Clean build folder
Step - 2: Delete the App installed in the device/simulator
Step - 3: Go to VSCode and move to ios directory using command line and just to be on the safer side, run the following command (just to remove build folder via VSCode as well)
rm -rf build
Step - 4: Run
pod install
Step - 5: Go back to the project folder and build the app again:
npx react-native run-ios
Context: react-native upgrade fails and cleaning the build folder doesn't work.
What works:
Trash out the node_modules folder.
Make yarn install to re-create dependencies.
It doesn't have any impact on "Podfile", but if you (future users) did, remove Podfile.lock, go to the ios folder and run pod install again. It must solve.
This is obviously overkill, but a reboot fixed this problem for me. I turned off my computer and turned it on again, and it's now working well.
When I log in to "Podfile" I will not be able to say why it does not work, but if you (future users) do it, remove Podfile.lock, go to the ios folder and run it again pod install. It must be resolved

"config.h" file not found in iOS project of React native

In X-Code project of react native, getting error
config.h file not found.
Here is version detail :
react-native-cli: 2.0.1
react-native: 0.51.0
How to solve it?
Close Xcode.
Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.4/
Run the configure script:
./configure
Open Xcode and try to run your app.
I had the same issue, using this steps solves for me:
Running into the same issue here after upgrading from 0.44. None of the above solutions or clearing caches did the trick for me. Here's what I did to get things working again:
In the Terminal, navigate to the react-native/third-party/glog folder inside node_modules (for me, this was cd node_modules/react-native/third-party/glog-0.3.4)
Once actively in this folder, run sh ../../scripts/ios-configure-glog.sh
Glog is configured and the required config.h header file is created for Xcode to find
Run your iOS BUILD
Regards!
When project files get messed up for me. I typically follow these steps.
rm -rf node_modules
npm install
react-native upgrade (Only changing affected files, so IOS for you)
react-native link
npm start --reset-cache
(In another terminal)
react-native run-ios
These steps worked for me:
rm -rf ~/.rncache
rm -rf node_modules/
npm install
npm start
You need to change to the legacy build system in Xcode 10 and install third party scripts manually.
1:
File -> Project/Workspace settings
Build System: dropdown -> change to Legacy Build system
2: Follow this to manually install third party scripts for RN:
Clean RN cache
$ rm -rf ~/.rncache
Re-install the deps
$ cd your_project_path
$ rm -rf node_modules/ && npm install
Then install the third-party
$ cd node_modules/react-native/scripts
$ ./ios-install-third-party.sh
Run the commands below if glog installation failed.
$ cd ../third-party/glog-0.3.x
$ ./configure
It works for me, I hope it helps for you.
If above all answers don't work,
Please check that there is no space in any directory name of the full path and not only the project directory name.
While in terminal, it accepts throgh My Disk as My\ Disk but xcode do not recognize that.
If its in My Disk directory, try after moving it to Desktop or any other directory which doesn't have space in their name.
configure: error: unsafe absolute working directory name Issue:
-Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.5/
Run the configure script:
./configure
got error: configure: error: unsafe absolute working directory name
try to created app in desktop and from there run ./configure command.
Please note with XCOXE 10, and Mojave MAC OS , I had same issue, ./configure was showing some permission issue, I had set permission "777" to project folder enclosing with inner folders
This is the linking issue in xcode. You just need to re-link the files.
Please follow the below steps:
Open you peoject's root directory then open node-module -> react-native -> React.
Open React.xcodeproj file in xcode.
You will see missing (showing red in color) files under the third-party folder
Just run the React.xcodeproj project.
After completion close this project & open you project file.
Delete Drive data & Clean the project & run.
If after running the project you are getting linking issue then please make sure you have added all the (ios) products () come under the Libraries -> React.xcodeproj -> Products in your Build Phases -> Link Binary With Libraries.
If everyone has tried solving the issue by this
Open Terminal, go to your project's root folder and run:
cd node_modules/react-native/third-party/glog-0.3.4/
Run the configure script:
./configure
But still not got the solution then,
Go to your Xcode and check if there any library is missing. Add that library and then perform this above step.
Although the already mentioned answers are correct but still few guys are struggling, as only configuring the glog doesn't sometimes resolve the error.
Here I have written a detailed solution to the problem.
Solution: config.h file not found mutex.h During Archive.
The steps are the following:
Remove node_modules directory
Clear Cache
Install packages again with Yarn
Install third party
Configure Glog
Make & Make install glog
For all these above steps the I have shared commands in the above mentioned article, so not going to write again. I hope it will solve problem for guys who are still struggling.

Code Sign Error in macOS Monterey, Xcode - resource fork, Finder information, or similar detritus not allowed

Already tried : Code Sign Error on macOS Sierra, Xcode 8
Please see image showing error
CodeSign /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app
cd "/Volumes/Development/Project/Top Best Games/19. Lets Flow/35/let's FLOW - source/proj.ios_mac"
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "iPhone Distribution: New Free Games (2CHN583K4J)"
Provisioning Profile: "Super Flow Flipp AppStore"
(c6c30d2a-1025-4a23-8d12-1863ff684a05)
/usr/bin/codesign --force --sign E48B98966150110E55EAA9B149F731901A41B37F --entitlements /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Intermediates/Flow.build/Debug-iphoneos/Super\ Flow\ Flip.build/Super\ Flow\ Flip.app.xcent --timestamp=none /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app
/Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super Flow Flip.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1
In Code Sign section its allowing me to select profile and certificate...but still giving error.
How to fix this problem ?
Solution 1:
Apple Developer Website Answers above problem Here.
Execute below command in terminal : First goto projects root folder
xattr -cr <path_to_project_dir>
Clean Xcode and Re-build.
Solution 2:
Just go to project root directory and run this command xattr -cr .
xattr -cr .
Clean Xcode and Re-build.
Solution 3:
You can fix this problem by finding files which holds finder information.
In terminal, goto project root directory and execute
ls -alR# . > kundapura.txt
This creates kundapura.txt in current directory. Now search for com.apple.FinderInfo and clear this attributes for all files. You can do it like this
xattr -c <filename>
Example: xattr -c guru.png
Once you clear all then code sign works. Clean Xcode and Re Build. Cheers
Solution 4: Inspired by Mark McCorkle's Answer
In terminal, goto project's root directory and execute one by one command
find . -type f -name '*.jpeg' -exec xattr -c {} \;
find . -type f -name '*.jpg' -exec xattr -c {} \;
find . -type f -name '*.png' -exec xattr -c {} \;
find . -type f -name '*.json' -exec xattr -c {} \;
Clean Xcode and Re-build.
The error is from attributes inside your image files. This happened from our graphics designer saving images from photoshop with attributes.
Here is a simple command to find all of your png files and remove their attributes. Run this in your projects root directory from terminal. Clean and rebuild; problem solved.
find . -type f -name '*.png' -exec xattr -c {} \;
If you have this error when codesigning an app:
resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1
Go to your project root folder and execute
find . | xargs -0 xattr -c
This will clear attributes for all files.
In Sierra, the rules on what can be in a signed bundle have been tightened, and resource forks are no longer allowed. AppleScript has been saving information in resource forks forever, although that information has been unused for a long time. With Sierra, when you save a script, this resource fork information will no longer be saved.
It means you cannot codesign a script that was last saved in a version before Sierra; you have to save in Sierra to be able to sign in Sierra.
The people likely to be affected by are who bundle other scripts within their scripts (cordova?). They will not be able to sign the container script until all the embedded scripts have been resaved under Sierra.
UPDATE:
Seems like this also works:
xattr -rc .
If you have any insufficient permissions error try to prepend sudo: sudo xattr -rc .
The easiest way to handle attributes on your source files is to have Xcode clear up the archive before it runs codesign. To do this:
Select your target in XCode
Select the Build Phases tab
Press the + symbol
Select New Run Script Phase
Enter the following for the script:
xattr -cr ~/Library/Developer/Xcode/DerivedData || echo Clear
Now when you build your target it will clear out any attributes that would have broken codesign. By clearing out at this stage you don't have to alter your source code / project directory.
The "|| echo Clear" part of the script ensures that the project build continues even if xattr errors.
This method is good if you use programs such as DropBox on your code repository that add the attributes, as it doesn't change your source project, only the built archive.
You may need to change the path to match your DerivedData directory - this path will be shown next to the codesign error.
I have used following command. Use terminal window. Navigate to your Project and execute following:
xattr -rc .
There is official Apple answer for this issue in Technical Q&A QA1940.
This is a security hardening change that was introduced with iOS 10,
macOS Sierra, watchOS 3, and tvOS 10.
Code signing no longer allows any file in an app bundle to have an
extended attribute containing a resource fork or Finder info.
To see which files are causing this error, run this command in
Terminal: xattr -lr <path_to_app_bundle>
You can also remove all extended attributes from your app bundle with
the xattr command: xattr -cr <path_to_app_bundle>
<path_to_app_bundle> can be replaced with directory of your Xcode project. For example ~/Development/MyProject
All about clearing files is fine, but tedious for multiple projects.
graphics apps, (like photoshop in old versions) write additional info (we now call it metadata..) in an old fashion in external files, or they came frm older OSX, files like:
"com.apple.ResourceFork" and "com.apple.FinderInfo", when unzipping folder, for example.
Xcode 8 refuses to add it to a build (as You added them to a project with a "git --add ." maybe..)
You can find in terminal recursively and delete them, but can be tedious.
I wrote a small free utility to delete it.. hope it can help..
https://itunes.apple.com/us/app/cleandetritus/id1161108431?ls=1&mt=12
For those (like me) who are just trying to develop an app without having to strip extended attributes on every new photoshop created PNG added to the macOS target, you can temporarily disable code signing by adding a user defined build setting:
CODE_SIGNING_ALLOWED = No
Obviously, one distributing an app needs to eventually deal with the issue but this enables development in cases like mine where it wasn't necessarily straightforward to omit code signing in Sierra (on past OS X / Xcode it was easier to do so).
Per RGriffith's comment, here are a few screenshots for those who aren't sure how the custom build setting is added.
Simple solution:-
How I did [Working for me]
Step 1:-
Go to this folder - from your finder press option Go - > Go to Folder
then type your project path like this
example:-
Library/Developer/Xcode/DerivedData/yourprojectname/Build/Products/Debug-iphoneos
Now you can see a window pop with list of available File, There you see yourApp.app file [ Don't do anything just wait for step 2].
Step 2:-
Open new Terminal and type just cd then just drag step 1 yourApp.app to terminal, now you will get the path for the app, now press enter button.
Step 3:-
Now type this command **
xattr -rc .
Don't miss "."(Dot) press enter button.
That's it, Go to your Xcode project and clean and run again.
-----In case you can't apply the solutions above, because of lack of bash knowledge or something else.
I had this problem as soon as I enabled iCloud Drive on my Sierra. And my project was in a folder which was synced with iCloud Drive. I suppose this is what adds those additional attributes.
Temporary solution:
Disable iCloud Drive for the folder where your project is.
You will need to delete the app bundle folder and rebuild the app as explained below.
My app is called: augment
In terminal window, goto your app folder
e.g.: cd /Users/username/Library/Developer/Xcode/DerivedData/
In terminal window run command for your app folder
e.g.: xattr -cr augment-flmbiciuyuwaomgdvhulunibwrms
Clean>Build>Run.
There is also a free app on Mac Appstore called "CleanDetritus" which will do removal of these.
This problem came to me yesterday.
(What's wrong) I updated image resources by manually replacing file in finder and I failed with this compilation error.
(What's right) Don't update image in this way. After that I dragged images to 'xcassets' in Xcode. No more error appear again.
My problem is every change I make in the code and execute again the error reappears. Then I find a solution to execute the command automatically every compilation/execution of code.
Thanks to #rich-able I discovered "Run Script". Then I put the command "xattr -cr ." in the field.
One of the best solution is
Go to terminal type this
xattr -cr "Full path of your project"
To find full path of your right click on Xcode project->get info -> copy path and replace with .
Then type below command
xattr -cr "Full path of your project"
Clean and build done.
The simplest fix may be if you are using git. Try:
$ git stash
$ git stash pop
Git does not store file metadata, the above will strip it all away.
Open terminal and just run this command.
xattr -cr "path to .app file"
I found that if I add color tag on the folder under DerivedData, it will give the above error when debug on device.
Remove the color Tag fix this error for me.
My problem was that I used cordova to build the app around 1 year ago, but it wasn't compatible with the new version of xcode, so I simply used cordova build ios and it worked again.
If the xattr commands doesn't the trick this may be due to an XCode 9 bug:
let's try to remove and re-add the resource folder (it was a .xcassets in my case) containing the affected files from Xcode. (you should understand which are the affected files previous through the xattr -lr command)
The problem is in the derived data, You should clean the derived data and then clean the project and build. Please check this link.
I'm also facing the same issue, got fixed by just restarting my Macbook.
You can remove the derived data
Xcode -> Preferences
And click on the arrow below Derived Data, and empty the folder Derived Data
I don't know what happened to me, but when I was running flutter app on simulator, I was encountered by the error. I used flutter clean command and removed the derived data and then everything goes fine.
My .app was on a network mounted drive.
codesign -f -vv --preserve-metadata=entitlements -s {*my Apple distribution cert SHA*} my.app
my.app: resource fork, Finder information, or similar detritus not allowed
I don't know if too long path or the fact it was on a NAS device was a problem. I copied the .app to my local Downloads directory, and then was able to codesign.
my.app: signed app bundle with Mach-O thin (arm64) [*com.something.my*]
This happened to me as well when I duplicated a .plist file and edited it, instead of creating a new one. the xattr -lr <path> command helped me identify the problematic file.
My issue was related to unintended changes on framework integrated using Carthage. I had modified one line in framework by mistake and it didn't show up in git because dependency build folder was ignored from git.
Solution : Deleted framework folder in Carthage and rebuilt it.

Xcode 8 can't archive "Command /usr/bin/codesign failed with exit code 1"

I've got a serious problem on Xcode 8 on macOS Sierra.
when I try to build my app, I get the following issue.
CodeSign /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp.app
cd /Users/me/Desktop/MyAppFolder1/MyAppFolder2/MyAppxcode
export CODESIGN_ALLOCATE=/Users/me/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Users/me/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Users/me/Downloads/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "-"
/usr/bin/codesign --force --sign - --timestamp=none /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp.app
/Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1
then I did https://forums.developer.apple.com/thread/48905 in the terminal as the following and it worked. but once I clean, the issue comes back.
cd /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Products/Debug-iphonesimulator/MyApp
ls -al# *
xattr -c *
and this solution doesn't work for archive with the following issue. is there any solution for it?
CodeSign /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
cd /Users/me/Desktop/MyAppFolder1/MyAppFolder2/MyAppxcode
export CODESIGN_ALLOCATE=/Users/me/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Users/me/Downloads/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Users/me/Downloads/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "iPhone Developer: My Name (**********)"
Provisioning Profile: "iOS Team Provisioning Profile: com.**********.*********"
(********-****-****-****-************)
/usr/bin/codesign --force --sign **************************************** --entitlements /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/MyApp.app.xcent --timestamp=none /Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
/Users/me/Library/Developer/Xcode/DerivedData/MyApp-gnoiiwnelmxzdidnijaswisrwdqe/Build/Intermediates/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1
I found this solution in the Apple forum
cd ~/Library/Developer/Xcode/DerivedData
xattr -rc .
or
xattr -rc ~/Library/Developer/Xcode/DerivedData
Solution 1:
You can try file specific bash command like Mark McCorkle answered.
In terminal, goto project's root directory and execute one by one command
find . -type f -name '*.jpeg' -exec xattr -c {} \;
find . -type f -name '*.png' -exec xattr -c {} \;
find . -type f -name '*.tif' -exec xattr -c {} \;
Clean Xcode and Re Build. Done.
Solution 2:
You can fix this problem by finding files which holds finder information.
In terminal, goto project root directory and execute
ls -alR# . > kundapura.txt
This creates kundapura.txt in current directory. Now search for com.apple.FinderInfo and clear this attributes for all files. You can do it like this
xattr -c <filename>
Example: xattr -c guru.png
Once you clear all then you are able to code sign. Cheers
For me worked this:
cd ~/Library/Developer/Xcode/DerivedData
xattr -dr com.apple.FinderInfo *
And then rebuild
There is a more permanent fix for this. Fixing the attributes in the DerivedData works, but the problem keeps coming back. What you need to do is go to the directory shown when you get the 'resource fork, Finder information, or similar detritus not allowed', the one that contains the .App file. Then execute...
xattr -lr MyAppName.App
You can then see the resource files that have the attributes that need removing. Don't remove them from the .App file though, find the original files in your project and open the directory that contains them and execute...
xattr -rc .
This then fixes the ORIGINAL files. Rebuild should then function ok. It should also then rebuild properly for archive too.
This gets caused by some resource files having extra attributes on the file system, probably caused by macOS Sierra (as I started having it after upgrading to macOS Sierra).
Try executing xattr -c * on the whole DerivedData folder (as stated by the answer in https://forums.developer.apple.com/message/178039#178039):
cd ~/Library/Developer/Xcode/DerivedData
xattr -c *
Removing attributes only on the build folder fixed the issue for me when debugging. Removing attributes on the whole DerivedData folder fixed it for me in archiving too. Please note that it may cause other consequences (albeit highly unlikely), but you can always delete the DerivedData folder and it will be regenerated, in case anything gets broken.
Also, if it still fails, cleaning the project (not the build folder) after executing the command is a good idea.
I had this problem with one file from CocoaPods bundle.
I've updated CocoaPods to the latest version and run:
pod install
after that, the problem has gone away.
in my case issue was with Provisioning Profiles and Account, i fixed by doing these steps:
Xcode Preferences ->Accounts->Delete already added account and add it again
Generate new Provisioning Profiles and installed in Xcode
clean project and rebuild it
I want to show my answer because it may be of interest (I have wasted a lot of time with this error)
None of the previous answers (which have a high score) have been useful to me.
They may be correct, but they haven't solved my problem.
Origin:
I added a new Target to my iOS application: iMessage
When I added png images to the Assets. xcassets, the error occurred.
Solution:
Make a copy of png images with "Apple Preview App" and uncheck Alpha.
Error message disappears.
In my case,
Go to
Xcode preference
Locations
Click on Project Path arrow
In DerivedData folder search for your project name
Select project folder, Right click and Move to trash
Done!
I encountered this error on macOS Sierra 10.12.3, Xcode 8.2.
Fixing the DerivedData did not work for me.
After I deleted an expired Apple Worldwide Developer Relations Certificate Authority certificate in Keychain Access the error went away.
Sometimes even if you fixed and/or had correct code-signing done, the problem might lurk in 3rd-party packages.
If you closely check out your build error, you might find the name of the 3rd-party libraries on the error message.
In this case, you must build your 3rd-party libraries again. For example in my case, update it via carthage update and now the build succeeded properly.

How to Completely Uninstall Xcode and Clear All Settings

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

Resources