xcode开发ios_如何下载Xcode并将其安装在Mac上-并更新它以进行iOS开发

xcode开发ios

Xcode is the tool developers use to build apps for the Apple ecosystem – MacOS, iOS, and all things Apple.

Xcode是开发人员用来为Apple生态系统(MacOS,iOS以及Apple的所有产品)构建应用程序的工具。

This guide will walk you through how to successfully install Xcode onto your Mac, from start to finish.

本指南将引导您从头到尾逐步将Xcode成功安装到Mac。

Here are some handy tips to know before you get started:

在您开始之前,这里有一些方便的提示:

  • Xcode only runs on a mac. If you are on a PC, sadly you won't be able to use Xcode.

    Xcode仅在Mac上运行。 如果您使用的是PC,那么您将无法使用Xcode。
  • You'll need a good, stable internet connection. The latest version is around 8 gigabytes in size.

    您需要一个良好,稳定的互联网连接。 最新版本的大小约为8 GB。
  • Be sure to have at least 30 gigabytes of free space on your computer. The latest .xip file (v11.4.1 at the time of writing) is ~8 gigabytes zipped. When you unzip it, that's another 17 gigabytes. Then you'll need the command line tool, which is yet another 1.5 gigabytes.

    确保计算机上至少有30 GB的可用空间。 最新的.xip文件(在撰写本文时为v11.4.1)压缩了约8 GB。 解压缩时,这又是17 GB。 然后,您将需要命令行工具,它又是1.5 GB。

这是安装Xcode步骤的概述 (Here's an overview of the steps to install Xcode)

  1. Download Xcode

    下载Xcode
  2. Install the command line tool

    安装命令行工具
  3. Open the new version

    打开新版本
  4. Delete files

    删除文件

Note that I have listed some Terminal commands in the steps below. These commands can be typed into your present working directory. This means that you don't need to navigate to any particular folder.

请注意,我在以下步骤中列出了一些终端命令。 这些命令可以输入到您当前的工作目录中。 这意味着您无需导航到任何特定的文件夹。

If you really want to, you can first type cd before typing the commands in the below steps. This will return you back to the home folder.

如果确实需要,可以先键入cd然后在以下步骤中键入命令。 这将使您返回到主文件夹。

步骤1:下载Xcode (Step 1: Download Xcode)

There are two ways to do this. For the latest version and a theoretically "easy" installation, you can use the App Store. I don't recommend this option.

有两种方法可以做到这一点。 对于最新版本和理论上“轻松”的安装,您可以使用App Store。 我不建议使用此选项。

I prefer to use the developer site. This comes with the bonus option of being able to download any version you'd like.

我更喜欢使用开发者网站。 附带的奖励选项是能够下载您想要的任何版本。

选项1:通过App Store下载最新版本(不是我的首选) (Option 1: Download via the App Store for the latest version (not my preferred option))

In theory, this should be a seamless and pain-free process. But if the installation fails for any reason on the last step, it is very hard to troubleshoot.

从理论上讲,这应该是一个无缝且无痛苦的过程。 但是,如果在最后一步由于任何原因安装失败,则很难进行故障排除。

There are a few reasons for failure, and no easy way to know which is the underlying cause. If you do encounter a failure, you will need to re-download the entire file again each time you try to fix the failure. As the latest version is 8 gigabytes, I didn't much enjoy this approach.

导致失败的原因有很多,并且没有简单的方法可以知道哪个是根本原因。 如果确实遇到故障,则每次尝试修复故障时都需要重新下载整个文件。 由于最新版本为8 GB,因此我不太喜欢这种方法。

But if you're feeling brave, here are the steps:

但是,如果您感到勇敢,请按以下步骤操作:

  • Open the App Store on your mac

    在Mac上打开App Store
  • Sign in

    登入
  • Search for Xcode

    搜索Xcode
  • Click install or update

    点击安装或更新

选项2:通过开发者网站下载特定版本(我的首选) (Option 2: Download via the Developer site for a specific version (my preferred option))

  1. Head to the "more" section of the Apple developer website

    前往Apple开发人员网站的“更多”部分

  2. Sign in with your iTunes account id

    使用您的iTunes帐户ID登录
  3. Type in the version that you'd like, and download the Xcode_x_x_x.xip file. Keep in mind that Xcode 11.4.1 is 8 gigabytes, so this will take awhile depending on your internet connection.

    输入您想要的版本,然后下载Xcode_x_x_x.xip文件。 请记住,Xcode 11.4.1为8 GB,因此这需要一段时间,具体取决于您的Internet连接。

  4. Once the file is downloaded, click on .xip to extract it. Your laptop will extract it to the same folder you downloaded it to. This extraction process is automatic. You don't need to do anything more after you click on the .xip file. This step will take a few minutes.

    下载文件后,单击.xip以将其.xip压缩。 您的笔记本电脑会将其解压缩到您下载到的文件夹中。 此提取过程是自动的。 单击.xip文件后,您无需执行任何其他操作。 此步骤将花费几分钟。

  5. [Optional] Once extracted, rename the application to “Xcode11.x.x” if you are using multiple versions.

    [可选]解压缩后,如果使用多个版本,则将应用程序重命名为“ Xcode11.xx”。
  6. Drag application to the Applications folder

    将应用程序拖到“应用程序”文件夹中
  7. [Optional] Set the new Xcode version as the default. Open Terminal and type sudo xcode-select -switch /Applications/Xcodex.x.x.app . Replace x.x.x with the version number. For example: Xcode11.4.1.app. You will need to enter in your computer admin password. I'm pretty sure this will update the default Xcode version for all users on your computer, so best to check with other users first

    [可选]将新的Xcode版本设置为默认版本。 打开终端,然后输入sudo xcode-select -switch /Applications/Xcodex.xxapp 。 用版本号替换xxx 。 例如: Xcode11.4.1.app 。 您将需要输入计算机管理员密码。 我很确定这会为您计算机上的所有用户更新默认的Xcode版本,因此最好先与其他用户联系

步骤2:安装命令行工具(CLT) (Step 2: Install the command line tool (CLT))

If you have multiple users on your computer, you will need to update the CLT for each user.

如果您的计算机上有多个用户,则需要为每个用户更新CLT。

Download .dmg

下载.dmg

To update the CLT, go to app developer website and download the command line tool .dmg.

要更新CLT,请访问应用程序开发者网站并下载命令行工具.dmg

If you have never installed Xcode before, you may be able to update with your Terminal by typing in xcode-select --install instead of visiting the developer website.

如果您以前从未安装过Xcode,则可以通过输入xcode-select --install而不用访问开发者网站来使用终端进行更新。

But if you have an existing version of Xcode installed on your machine, you'll probably see this error:

但是,如果您的计算机上安装了现有版本的Xcode,则可能会看到此错误:

xcode-select: error: command line tools are already installed, use “Software Update” to install updates

This means you'll need to go to the developer website instead.

这意味着您需要转到开发者网站。

安装CLT (Installing the CLT)

When the .dmg has finished downloaded, double click the file to open it. This will open a little window that looks like this:

.dmg下载完成后,双击该文件将其打开。 这将打开一个小窗口,如下所示:

Double click the box and follow the prompts to install the CLT. It will take a few minutes to complete.

双击该框,然后按照提示安装CLT。 这将需要几分钟才能完成。

It may ask you at the end of the installation whether you want to move this to the trash bin. When it does this, it's talking about moving the .dmg file to the trash bin. Since you should no longer need this file. I always say yes to this.

在安装结束时,它可能会询问您是否要将其移至垃圾箱。 当这样做时,它是在谈论将.dmg文件移动到垃圾箱。 由于您不再需要此文件。 我总是对此表示赞同。

步骤3:开启Xcode (Step 3: Open Xcode)

Open the Applications folder and open the new version of Xcode. If you renamed Xcode, make sure you open the correct application

打开“应用程序”文件夹,然后打开新版本的Xcode。 如果您重命名了Xcode,请确保打开正确的应用程序

Xcode may prompt you to install additional components. Click install. This will take a few minutes.

Xcode可能会提示您安装其他组件。 单击安装。 这将需要几分钟。

While it's installing, check that your default Xcode version is the one you just downloaded:

在安装时,请检查您的默认Xcode版本是否为您刚刚下载的版本:

  • Open Terminal

    开放终端
  • Type brew config

    键入brew config

  • You should see “CLT” and “Xcode” versions, as well as everything else. This should reflect the version that you have just downloaded. In my case, I downloaded Xcode 11.4.1.

    您应该看到“ CLT”和“ Xcode”版本,以及其他所有版本。 这应该反映您刚刚下载的版本。 就我而言,我下载了Xcode 11.4.1。
CLT: 11.4.1.0.1.1586360307
Xcode: 11.4.1 => /Applications/Xcode11.4.1.app/Contents/Developer

Once the components are installed, Xcode will launch. You should be able to pick up your old projects and continue where you left off seamlessly*.

一旦安装了组件,Xcode将启动。 您应该能够接管您的旧项目,并继续无缝地从您离开的地方*。

*Note that if you use any proxy tools, such as Charles, you will need to re-install those certificates in your simulator again.

*请注意,如果您使用任何代理工具(例如Charles),则需要再次在模拟器中重新安装这些证书。

If you encounter any errors while trying to build or run a project, check which device you are trying to launch. The new version may not remember the device you were using before. If so, click on the device and choose "Add additional simulators" from the drop down menu to add the device you want.

如果在尝试构建或运行项目时遇到任何错误,请检查要尝试启动的设备。 新版本可能不记得您之前使用的设备。 如果是这样,请单击设备,然后从下拉菜单中选择“添加其他模拟器”以添加所需的设备。

步骤4.删除文件 (Step 4. Delete the files)

If you don't need the older versions of Xcode on your computer, you can uninstall them and get some hard drive space back.

如果您的计算机上不需要较旧版本的Xcode,则可以将其卸载并获得一些硬盘空间。

You can also delete the .xip file of the version you just downloaded, as well as the CLT.dmg file.

您也可以删除.xip你刚刚下载的版本文件,还有CLT.dmg文件。

That's everything. I hope this has helped you successfully install Xcode. Have fun with it!

就是这样 我希望这可以帮助您成功安装Xcode。 玩得开心!

翻译自: https://www.freecodecamp.org/news/how-to-download-and-install-xcode/

xcode开发ios

你可能感兴趣的:(python,java,linux,数据库,mac)