Building Swift Compiler on specific branch
Hi all, I’m @kitasuke, iOS Engineer.
I summarized build flow for Swift Compiler mainly for myself.
In this post, I’ll cover how to build swift-5.0-branch
and master
branches.
swift-5.0-branch
I use master
branch most of times, but I do use a specific branch sometimes.
1. Update all repositories on specific branch
$ cd swift-source/swift
$ ./utils/update-checkout --scheme swift-5.0-branch
As above, specify a branch name with --scheme
option, so that update-checkout
script actually checks out the branch and update contents to the latest one.
Now you can see the branch as below.
$ swift git:(swift-5.0-branch)
2. Update Toolchain
There are two ways to set toolchain we want for Swift Compiler.
Download compatible Toolchain
Download a toolchain you want from website below. In this case, Swift 5.0 Development would be fine.
Next, choose the toolchain in Xcode you selected as xcode-select
path. Go to Preferences -> Components
and tap Toolchains
tab to choose.
Download compatible Xcode
You can use compatible Xcode instead. Download Xcode 10.2 Beta in this case because it supports Swift 5.0.
$ swift -v $ Apple Swift version 5.0 (swiftlang-1001.0.60.3 clang-1001.0.37.8)
Run command below to change path to use Xcode Beta.
$ sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer
master branch
It’s almost same flow as the one for swift-5.0-branch
.
1. Update all repositories on specific branch
$ cd swift-source/swift
$ ./utils/update-checkout --scheme master
Specify master
with --scheme
option and confirm it's updated.
$ swift git:(master)
2. Update Toolchain
In my opinion, it’s better to use Toolchain when you use master
branch.
Download compatible Toolchain
Download and use Trunk Development (master) for this case.
Download compatible Xcode
At this moment, I’m able to build Swift Compiler by Xcode 10.2 Beta, but master
branch will be ahead most of times. So be careful to check whether it's compatible.
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Takeaway
Building Swift Compiler is hard because it’s failed sometimes without clear reasons. It’s quite important to make sure that you set appropriate environment configuration when you build.
Have a fun debug with Swift Compiler!