如何从 xip 文件安装 Xcode

我对 macOS 很陌生,我只需要一个带 Xcode 的 mac 来编译我的应用程序。然而,对于 macosSierra,我的 USB 有一个问题,它不再工作了(我不能插入我的 ipad pro)

在 OSX El Capitan下,我的 usb 工作得很好,但现在的问题是,应用商店提供给我下载 Xcode 8.3只能在 Sierra 上工作(奇怪的是,他们提供给你下载一些与你的系统不兼容的东西,但没关系,这是苹果)。所以我唯一的办法就是手动下载 Xcode 8.2.1

现在我的问题是,如何安装我刚下载的 Xcode_8.2.1.xip文件?在不久的将来,如果我需要更新 xcode (我猜想自己下载一个新版本) ,我该怎么办?首选项和配置设置也保存在哪里?这些首选项是否会在每次更新时丢失?

157027 次浏览

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.

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

Update: 17 May, 2020: Most easy way

  • Download the specific Xcode version that you want from here
  • 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

xip -x Xcode_12.4.xip command won't install under /Applications/Utilities

/Applications/Utilities requires sudo permission. So, you should run like: sudo xip -x /tmp/Xcode_12.4.xip under /Applications/Utilities path