如何自动安装 Xcode?
我正在尝试编写一个 shell 脚本来安装我们所有的开发工具和工具。依赖于干净的 OSX 机器。
有人知道自动化安装 Xcode 的最佳方法吗?
我这样做是为了:
- 记录开发环境。
- 加快新开发人员的入职流程。
- 遵循一切自动化原则。
I am trying to write a shell script that will install all of our development tools & dependencies onto a clean OSX machine.
Does anybody know the best approach to automate the installation of Xcode?
I am doing this to:
- Document the development environment.
- Speed up the on-boarding process for new developers.
- Follow the automate-everything principle.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
全自动 XCode 安装
首先,登录Apple 开发者下载站点< /a> 并获取适用于您的 OSX 版本的 XCode.dmg 版本。您可能想要获取几个版本来支持不同的 OSX 平台(例如:10.10 Yosemite、10.9 Mavericks 等)。将 dmg 上传到您可以访问的文件主机(例如:Amazon S3、Dropbox、您选择的共享托管提供商等...)
更改以下内容中的
DOWNLOAD_BASE_URL
脚本,并使用版本和名称适当地重命名 dmg。内部版本号或将其添加到下面的脚本:您可能有兴趣安装 XCode 命令行工具,并绕过 XCode 许可协议:
替代方法
另一种方法是使用 我创建的这个 applescript。
使用:
您可能也对我的答案感兴趣:如何下载和安装 Xcode 的命令行工具。
我会推荐其他方法而不是 applescript 方法。 applescript 依赖于 UI 元素层次结构,对于 OSX 上的 App Store 应用程序的未来版本来说,该层次结构可能并不总是保持不变。对我来说它似乎很脆弱。通过命令行通过 dmg 安装 XCode 可能是最可靠的方法。
Fully Automated XCode Installation
First, login to the Apple Developer Downloads Site and get the version of XCode.dmg that works for your version of OSX. You might want to grab a couple versions to support the different OSX platforms (e.g.: 10.10 Yosemite, 10.9 Mavericks, etc...). Upload the dmg to a file host you can access (e.g.: Amazon S3, Dropbox, your shared hosting provider of choice, etc...)
Change the
DOWNLOAD_BASE_URL
in the following script, and rename the dmgs appropriately with the version & build number or add it to the script below:You might be interested in installing the XCode Command Line Tools, and bypassing the XCode License Agreement also:
Alternative Method
An alternative is to use this applescript I created.
To use:
You might also be interested in my answer here: How download and Install Command Line Tools for Xcode.
I would recommend the other method over the applescript method. The applescript depends on a UI element hierarchy that may not always stay the same for future versions of the App Store app on OSX. It just seems fragile to me. Installing XCode via the command line via a dmg is probably the most reliable way.
好吧,对于到达此页面的人来说,Fastlane 的作者之一构建了一个 gem 来自动执行此过程。
https://github.com/KrauseFx/xcode-install
Well, just for who reach this page, there is a gem build by one of author of Fastlane to automatic this process.
https://github.com/KrauseFx/xcode-install
从 Xcode 4.3 开始,它作为应用程序包提供。第一次启动该应用程序时,它将继续安装。由于它是测试版,因此尚未修复,但目前启动后安装包位于应用程序包中名为 Contents/Resources/Packages 的目录中。
因此,根据您的环境,您的安装脚本只需将 Xcode.app 捆绑包复制到应用程序目录中,您的用户就可以在第一次启动它时完成安装。或者,您可以复制该捆绑包,然后使用
installer(8)
实用程序手动安装其他软件包。有关使用安装程序的更多信息,请参阅 手册页。Starting with Xcode 4.3, it's delivered as an app bundle. The first time you launch the app, it will continue the installation. Since it's a beta, it's still not fixed, but currently the post-launch installation packages are in the app bundle inside a directory called Contents/Resources/Packages.
So, depending on your environment, your install script can just copy the Xcode.app bundle into the Applications directory and your users can complete the installation the first time they launch it. Or, you can copy the bundle and then manually install the additional packages using the
installer(8)
utility. For more information on using installer, see the man pages.许多用于自动下载和安装的东西已经过时了。我一直在为另一个项目做一些事情,并且认为我有一个非常好的解决方案:
https://github.com/rockholla/macosa/blob/master/bin/macosa_xcode
这是下载部分:
https://github.com/rockholla/macosa/blob/master/bin/macosa_xcode_download< /a>
A lot of things of things out there for automating both downloading and installing are outdated. I've been at work on something for another project and think I have a pretty good solution working:
https://github.com/rockholla/macosa/blob/master/bin/macosa_xcode
And here's the download part:
https://github.com/rockholla/macosa/blob/master/bin/macosa_xcode_download