How to install Xcode from xip file

XcodeXcode8

Xcode Problem Overview


I am very new to macOS, I just need a mac with Xcode to compile my app. However, with macOS Sierra, I have a problem with my USB that is not working anymore (i can't plug my ipad pro)

Under OSX el capitan my usb works great, but now the problem is that app store offer me to download the Xcode 8.3 only that can work only on Sierra (strange they offer you to download something not compatible with your system but doesn't matter, it's apple). so the only way i have is to download manually the xcode 8.2.1

Now my question, how to install the Xcode_8.2.1.xip I just downloaded? and in near future, if I need to update xcode (I guess downloading myself a new version), how will I do? Also where the preferences and configurations settings are saved? does these preferences will be lost on each update?

Xcode Solutions


Solution 1 - Xcode

Double-click the xip file and it will extract the Xcode application. Move Xcode to the Applications folder and you are good to go.

The App Store should present the Xcode update once you update to Sierra (macOS 10.12). If it doesn't you can download Xcode directly from the App Store. The preferences are stored in /Users/<username>/Library/Preferences and are not impacted by updating the version of Xcode or OS.

Solution 2 - Xcode

For example, if a XIP file is located on your desktop: open the “Terminal” application found in /Applications/Utilities/ and run the following command:

 xip -x ~/Desktop/Xcode_8.2.1.xip

Solution 3 - Xcode

Update: 17 May, 2020: Most easy way

- Download the specific Xcode version that you want [from here][1]
- Add the downloaded Xcode.xip in Applications 
- Double click on it, it will start expand. It will take some time.
- If you have multiple Xcode version like 12.0, 12.1 in Applications rename it accordingly.
- Double click on extracted Xcode version and install tools.
- To set default Xcode version run this command: 

    sudo xcode-select -switch /Applications/Xcode_12.1.app

- To check default Xcode version in your system use this command:

    /usr/bin/xcodebuild -version

Note: Set default xcode step can be skip if you don't have multiple xcode versions in Applications.

Update: 08 Oct, 2020: Easy way

Old Ans

Convert the xip to a dmg by opening a terminal to the folder where the xip is placed and run the following commands:

$ open Xcode_X_Y_Z.xip
  $ mkdir Xcode-tmp
  $ mv Xcode.app Xcode-tmp/Xcode.app
  $ hdiutil create -volname "Xcode" \
            -srcfolder Xcode-tmp \
            -ov -format UDZO \
            Xcode_X.Y.Z.dmg
  $ rm -rf Xcode-tmp

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionzeusView Question on Stackoverflow
Solution 1 - XcodewintermuteView Answer on Stackoverflow
Solution 2 - XcodeДмитрий ВасильевView Answer on Stackoverflow
Solution 3 - XcodeDivyesh_08View Answer on Stackoverflow