我可以安装多个 Xcode 版本吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/669367/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:59:19  来源:igfitidea点击:

Can I have multiple Xcode versions installed?

xcodemacos

提问by Dana Holt

Is it possible to have more than one version of Xcode installed at the same time?

是否可以同时安装多个版本的 Xcode?

If so, please post any tip, tricks, or potential issues to watch out for.

如果是这样,请发布任何需要注意的提示、技巧或潜在问题。

EDIT:

编辑:

The reason I want to install multiple versions is to try out the new sdk beta, but if the new Xcode is buggy I want to be able to use the older version for my existing projects.

我想安装多个版本的原因是尝试新的 sdk 测试版,但如果新的 Xcode 有问题,我希望能够将旧版本用于我现有的项目。

采纳答案by MattK

Yes, you can install multiple versions of Xcode. They will install into separate directories. I've found that the best practice is to install the version that came with your Mac first and then install downloaded versions, but it probably doesn't make a big difference. See http://developer.apple.com/documentation/Xcode/Conceptual/XcodeCoexistence/Contents/Resources/en.lproj/Details/Details.htmlthis Apple Developer Connection page for lots of details.<- Page does not exist anymore!

是的,您可以安装多个版本的 Xcode。它们将安装到单独的目录中。我发现最佳做法是先安装 Mac 随附的版本,然后再安装下载的版本,但这可能没有太大区别。有关大量详细信息,请参阅http://developer.apple.com/documentation/Xcode/Conceptual/XcodeCoexistence/Contents/Resources/en.lproj/Details/Details.html这个 Apple Developer Connection 页面。<- 页面不存在了!

回答by Jim Rhoades

It's easy to have multiple Xcode installs.

安装多个 Xcode 很容易。

In the installer there's a pulldown for the location... you just need to pick a new location when you're installing the beta version.

在安装程序中,有一个位置下拉菜单……您只需要在安装测试版时选择一个新位置即可。

These instructions from an Apple dev tools evangelist have the full details (Apple dev username/password required): https://devforums.apple.com/message/40847#40847

来自 Apple 开发工具布道者的这些说明具有完整的详细信息(需要 Apple 开发用户名/密码):https: //devforums.apple.com/message/40847#40847

Then grab yourself a custom icon for the Beta version of XCode you're using, so you can tell them apart in the dock: http://iphonedevelopment.blogspot.com/2009/03/multiple-developer-tool-installs.html

然后为您正在使用的 XCode 测试版获取自定义图标,以便您可以在 Dock 中区分它们:http: //iphonedevelopment.blogspot.com/2009/03/multiple-developer-tool-installs.html

回答by Randika Vishman

Can I have multiple Xcode versions installed?

我可以安装多个 Xcode 版本吗?

Solution:
Actually as many of the above answers says, it is possible. Even according to the following Oracle Mobile Platform Blog, you can install more than one XCodes in the same Mac. The reason why you need to do that may vary according to you.

解决方案:
实际上正如上述许多答案所说,这是可能的。即使根据以下Oracle 移动平台博客,您也可以在同一台 Mac 中安装多个 XCode。您需要这样做的原因可能因您而异。

Scenario:
You might have installed only one version of XCode for now. Mostly the one release behind the latest XCode version which is available through App Store (mine I've Xcode 6.3.2 and I needed to keep it and also install Xcode 7 which is available through App Store).

For Ex:-

场景:
您现在可能只安装了一个版本的 XCode。主要是最新的 XCode 版本背后的一个版本,可通过 App Store 获得(我的 Xcode 6.3.2,我需要保留它并安装可通过 App Store 获得的 Xcode 7)。

例如:-

You have already installed XCode 6.x, and App Store has XCode 7 already given by App Store. For any reason you need to keep that Older XCode 6.x(as you know it is stable for some time now) and also you need to install and try out new XCode 7

So number one question might be, How and Wherecould you download the Mac OS X installable DMG file for XCode 7 (or may be if you wanna try out an older XCode version)? Ok, here is the direct link apple downloads(you might have to log into Apple Developer account before viewing this link correctly), or else following is a StackOverflow Q&A link which gives the answer to where to download DMG files for XCode IDEs.

你已经安装了 XCode 6.x,App Store 已经有 App Store 提供的 XCode 7。无论出于何种原因,您都需要保留旧的 XCode 6.x(正如您所知,它现在已经稳定了一段时间)并且您还需要安装并试用新的 XCode 7

所以第一个问题可能是,您可以如何以及在哪里下载用于 XCode 7 的 Mac OS X 可安装 DMG 文件(或者如果您想尝试较旧的 XCode 版本)?好的,这是苹果下载的直接链接(在正确查看此链接之前,您可能必须登录 Apple 开发者帐户),或者以下是StackOverflow 问答链接,它给出了从何处下载 XCode IDE 的 DMG 文件的答案

So now let's assume that you have obtained any of the DMG file for the XCode version you require to install as secondarily?

那么现在让我们假设您已经获得了您需要作为辅助安装的 XCode 版本的任何 DMG 文件?

Steps:
Follow the steps given bellow which I got from the above given first link of Oracles Mobile Platform Blog.

步骤:
按照我从上面给出的 Oracle 移动平台博客的第一个链接中获得的下面给出的步骤进行操作。

  1. Close Xcode if running
  2. Rename /Applications/Xcode.appto /Applications/Xcode_6.x.app
  3. Enter the admin password when prompted
  4. Double click the DMG file of your required, pre-downloaded Xcode and install it
  5. Once installed it, before running it, change the new /Applications/Xcode.appthat was just installed to (according to my above given example) /Application/Xcode_7.app
  1. 如果运行,请关闭 Xcode
  2. 重命名/Applications/Xcode.app/Applications/Xcode_6.x.app
  3. 出现提示时输入管理员密码
  4. 双击所需的预下载 Xcode 的 DMG 文件并安装它
  5. 安装后,在运行之前,将/Applications/Xcode.app刚刚安装的新更改 为(根据我上面给出的示例)/Application/Xcode_7.app

Note*:

笔记*:

[Please patiently read this section until the next Note]When you have two versions of Xcode installed, your workstation has two versions of Command Line Tool (xcodebuild) installed too. The question is what your Terminal and Xcode build command will use to when you are building your iOS App. Because along with the Command Line Tool, iOS SDK which is being used to build your app also depends on.

[请耐心阅读本节直到下一个注意]当您安装了两个版本的 Xcode 时,您的工作站也安装了两个版本的命令行工具 ( xcodebuild)。问题是当您构建 iOS 应用程序时,您的终端和 Xcode 构建命令将使用什么。因为与命令行工具一起,用于构建您的应用程序的 iOS SDK 也取决于。

My experience was I've had two Xcode versions. Xcode 10 (Old one with iOS12.0 - iphoneos12.0), and Xcode 10.1 (New one with iOS 12.1 - iphoneos12.1). So obviously the settings for Command Line Tool was selected to use xcodebuildtool from the Old app. I had to manually select it in Xcode preference window.

我的经验是我有两个 Xcode 版本。Xcode 10(旧的 iOS12.0 - iphoneos12.0)和 Xcode 10.1(新的 iOS 12.1 - iphoneos12.1)。很明显,命令行工具的设置被选择为使用xcodebuild旧应用程序中的工具。我必须在 Xcode 首选项窗口中手动选择它。

Where to set Command Line Tool in Xcode Preference Window?

在 Xcode 首选项窗口中在哪里设置命令行工具?

  • Select the Locationstab and there, you can select all the installed versions of Command Line Tools (which is xcodebuild).
  • 选择Locations选项卡,然后您可以选择所有已安装的命令行工具版本(即xcodebuild)。

How to figure out which version of iOS SDK is being used to build your iOS App?

如何确定正在使用哪个版本的 iOS SDK 来构建您的 iOS 应用程序?

  • On your Terminal issue following command: $> xcodebuild -showsdks
  • Above command should print out all the SDK details which your current Xcode configuration uses to build your Apps. And by seeing the results you will understand that your iOS/iphoneos SDK version depends on changing Command Line Tool (xcodebuild) setting on your Xcode.
  • 在您的终端发出以下命令: $> xcodebuild -showsdks
  • 上面的命令应该打印出您当前 Xcode 配置用于构建应用程序的所有 SDK 详细信息。通过查看结果,您将了解您的 iOS/iphoneos SDK 版本取决于更改xcodebuildXcode上的命令行工具 ( ) 设置。

Note**:
Above given Apple Downloads link and Oracles MPF blog post links might change and/or unavailable in the future.

注意**:
以上给出的 Apple 下载链接和 Oracles MPF 博客文章链接将来可能会更改和/或不可用。

So I hope that my this answer might be helpful to somebody else out there!
Cheers!

所以我希望我的这个答案可能对其他人有所帮助!
干杯!

回答by Eric Chan

You may want to use the "xcode-select" command in terminal to switch between the different Xcode version in the installed folders.

您可能希望在终端中使用“xcode-select”命令在已安装文件夹中的不同 Xcode 版本之间切换。

回答by Ashley Mills

It seems that Xcode really likes to be in the Applications folder and be called Xcode, especially when using xcodebuild(when building for Carthage for example) - and xcode-selectdoesn't always seem to cut it.

看起来 Xcode 真的很喜欢位于 Applications 文件夹中并被称为 Xcode,尤其是在使用时xcodebuild(例如为 Carthage 构建时) - 并且xcode-select似乎并不总是削减它。

I have a client project that's still using Swift 2.2, and I'm stuck on Xcode 7 for that and using Xcode 8 for anything else.

我有一个仍在使用 Swift 2.2 的客户端项目,为此我坚持使用 Xcode 7,而将 Xcode 8 用于其他任何事情。

So, in my Applications folder, I have Xcode 7 (renamed to Xcode_7) and Xcode 8 (renamed to Xcode_8). Then I rename whichever one I need to simply Xcode, and back again when done. It's a ball-ache, but seems to work.

因此,在我的 Applications 文件夹中,我有 Xcode 7(重命名为Xcode_7)和 Xcode 8(重命名为Xcode_8)。然后我将我需要的任何一个重命名为Xcode,并在完成后再次返回。这是一个球痛,但似乎工作。

This shell script simplifies it a bit…

这个shell脚本简化了一点……

xcode-version.sh

xcode-version.sh

cd /Applications

if  [[  = "-8" ]]
then 
    if [ -e Xcode_8.app ] 
    then            
        mv Xcode.app Xcode_7.app
        mv Xcode_8.app Xcode.app
        echo "Switched to Xcode 8"
    else
        echo "Already using Xcode 8"
    fi
elif  [[  = "-7" ]]
then
    if [ -e Xcode_7.app ] 
    then            
        mv Xcode.app Xcode_8.app
        mv Xcode_7.app Xcode.app
        echo "Switched to Xcode 7"
    else
        echo "Already using Xcode 7"
    fi
else
    echo "usage: xcode-version -7/8"
fi

xcode-select --switch Xcode.app

回答by ThomasW

Note that if you use the xcodebuildcommand line tool, then the last version of Xcode installed will become the default version. (A symbolic link is installed in /usr/bin.) To use the xcodebuildfor the other versions of Xcode you'll need to use the version in the (xcode_install_directory)/usr/bindirectory.

请注意,如果您使用xcodebuild命令行工具,则安装的最后一个 Xcode 版本将成为默认版本。(符号链接安装在 /usr/bin 中。)要使用xcodebuildXcode 的其他版本,您需要使用(xcode_install_directory)/usr/bin目录中的版本。

noteTo switch between different versions of the Xcode command-line tools, use the xcode-selecttool mentioned by other commenters.

注意要在不同版本的 Xcode 命令行工具之间切换,请使用xcode-select其他评论者提到的工具。

回答by bauerMusic

Staring with Xcode 9, the beta Xcode is labeled 'Xcode-beta.app' and is designed to live side by side with the production version. Info can be found in the Xcode release noteshere. (Not using direct link because it breaks often).

Xcode 9 开始,测试版 Xcode 被标记为“Xcode-beta.app”,旨在与生产版本并存。信息可以在此处的 Xcode发行说明中找到。(不使用直接链接,因为它经常中断)。

From Apple:

来自苹果:

Xcode 9 beta 4 can coexist with previous versions of Xcode. Prerelease versions of Xcode are made available from developer.apple.com, packaged in a compressed XIP file. To install Xcode during the beta period, download the XIP file, double-click the file to expand it in place, then drag Xcode-beta.app to the Applications folder

Xcode 9 beta 4 可以与之前版本的 Xcode 共存。Xcode 的预发布版本可从 developer.apple.com 获得,打包在一个压缩的 XIP 文件中。测试期间安装Xcode,下载XIP文件,双击文件展开到位,然后将Xcode-beta.app拖到Applications文件夹

回答by cseder

Install Multiple Versions Of Xcode using the Xcode-Install Ruby Gem

You can do this whole process a lot easier if you use the xcode-install RubyGem.

使用 Xcode-Install Ruby Gem 安装多个版本的 Xcode

如果您使用xcode-install RubyGem,您可以更轻松地完成整个过程 。

If you already have a working installation of the Xcode CommandLineTools and Ruby (I'd suggest using Homebrewfor installing Ruby) but I think it works with the Ruby supplied by macOS as well if you install the Gem either using sudo or as a user install. (Details on the GitHub page) Basically:

如果您已经安装了 Xcode CommandLineTools 和 Ruby(我建议使用Homebrew安装 Ruby),但我认为它也适用于 macOS 提供的 Ruby,如果您使用 sudo 或作为用户安装安装 Gem . (GitHub页面上的详细信息)基本上:

    $ gem install xcode-install
    $ xcversion list
    6.0.1
    6.1
    6.1.1
    6.2 (installed)
    6.3
    $ xcversion install 8
    ######################################################################## 100.0%
    Please authenticate for Xcode installation...

    Xcode 8
    Build version 6D570

To select a version as active, you'll run:
$ xcversion select 8

要选择一个版本为活动版本,您将运行:
$ xcversion select 8

To select a version as active and change the symlink at /Applications/Xcode, you'll run:
$ xcversion select 8 --symlink

要选择活动版本并更改 /Applications/Xcode 中的符号链接,您将运行:
$ xcversion select 8 --symlink

xcode-install can also manage your local simulators using the simulators command.

xcode-install 还可以使用模拟器命令管理您的本地模拟器。

Read the instructions on the GitHub Project page for more info.

阅读 GitHub 项目页面上的说明以获取更多信息。

回答by fleurdeviande

To have multiple Xcode instances installed you can put them to different folders for example /Developer5.0.2/Xcode, but to use them in CI or build environment(command line) you need to setup some environment variables during the build. You can have more instructions here. So it is working not just with beta and fresh release, also it's working for the really old versions, you might need it to use with Marmalade or Unity plugins which is not support the latest Xcode versions yet(some times it's happens).

要安装多个 Xcode 实例,您可以将它们放在不同的文件夹中,例如 /Developer5.0.2/Xcode,但是要在 CI 或构建环境(命令行)中使用它们,您需要在构建过程中设置一些环境变量。您可以在此处获得更多说明。因此,它不仅适用于测试版和新版本,还适用于真正的旧版本,您可能需要将它与尚不支持最新 Xcode 版本的 Marmalade 或 Unity 插件一起使用(有时会发生)。

回答by katwal-Dipak

  1. First, remove the current Xcode installation from your machine. You can probably skip this step but I wanted to start fresh. Plus?—?Xcode was behaving a little weird lately so this is a good opportunity to do that.
  2. Install Xcode 8 from the App Store. Make sure project files (.xcodeproj) and workspace files (.xcworkspace) can be opened with the new Xcode installation (remember to select the Later option whenever prompted).
  3. Download the Xcode 7.3.1 dmg file from Apple. Double-tap the newly downloaded dmg file in order to get the standard “Drag to install Xcode in your Applications folder”. Don't do that. Instead, drag the Xcode icon to the desktop. Change the file name to Xcode 7.3.1. Now drag it to the Applications folder.
  1. 首先,从您的机器中删除当前的 Xcode 安装。您可能可以跳过这一步,但我想重新开始。另外?—?Xcode 最近表现得有点奇怪,所以这是一个很好的机会。
  2. 从 App Store 安装 Xcode 8。确保可以使用新的 Xcode 安装打开项目文件 ( .xcodeproj) 和工作区文件 (.xcworkspace)(请记住在出现提示时选择“稍后”选项)。
  3. 从 Apple 下载 Xcode 7.3.1 dmg 文件。双击新下载的 dmg 文件以获得标准的“拖动以在应用程序文件夹中安装 Xcode”。不要那样做。相反,将 Xcode 图标拖到桌面上。将文件名更改为 Xcode 7.3.1。现在将其拖到 Applications 文件夹中。

Now you have two versions of Xcode installed on your machine. Xcode 7.3.1 and Xcode 8.

现在您的机器上安装了两个版本的 Xcode。Xcode 7.3.1 和 Xcode 8。

Details: Install Xcode 7 & Xcode 8 side by side

详细信息:并排安装 Xcode 7 和 Xcode 8