Skip to content

Commit 98ced88

Browse files
committed
[docs] GettingStarted.md: Make integration with Ninja the recommended Xcode workflow
...now that the build-script `--xcode` option implies `--skip-build`.
1 parent 0c46580 commit 98ced88

File tree

1 file changed

+26
-61
lines changed

1 file changed

+26
-61
lines changed

docs/HowToGuides/GettingStarted.md

Lines changed: 26 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ toolchain as a one-off, there are a couple of differences:
2424
- [Troubleshooting build issues](#troubleshooting-build-issues)
2525
- [Editing code](#editing-code)
2626
- [Setting up your fork](#setting-up-your-fork)
27-
- [First time Xcode setup](#first-time-xcode-setup)
2827
- [Using Ninja with Xcode](#using-ninja-with-xcode)
2928
- [Other IDEs setup](#other-ides-setup)
3029
- [Editing](#editing)
3130
- [Incremental builds with Ninja](#incremental-builds-with-ninja)
32-
- [Incremental builds with Xcode](#incremental-builds-with-xcode)
3331
- [Spot checking an incremental build](#spot-checking-an-incremental-build)
3432
- [Reproducing an issue](#reproducing-an-issue)
3533
- [Running tests](#running-tests)
@@ -212,7 +210,7 @@ to understand what the different tools do:
212210
git repositories together, instead of manually cloning/updating each one.
213211
6. `utils/build-script` (we will introduce this shortly)
214212
is a high-level automation script that handles configuration (via CMake),
215-
building (via Ninja or Xcode), caching (via Sccache), running tests and more.
213+
building (via Ninja), caching (via Sccache), running tests and more.
216214
217215
> **Pro Tip**: Most tools support `--help` flags describing the options they
218216
> support. Additionally, both Clang and the Swift compiler have hidden flags
@@ -232,37 +230,20 @@ Phew, that's a lot to digest! Now let's proceed to the actual build itself!
232230
small compared to build artifacts. You can bump it up, say by setting
233231
`export SCCACHE_CACHE_SIZE="50G"` in your dotfile(s). For more details,
234232
see the [Sccache README][Sccache].
235-
2. Decide if you would like to build the toolchain using Ninja or using Xcode.
236-
- If you use an editor other than Xcode and/or you want somewhat faster builds,
237-
go with Ninja.
238-
- If you are comfortable with using Xcode and would prefer to use it,
239-
go with Xcode. If you run into issues building with Xcode, you can alternatively [integrate a Ninja build into Xcode](#integrate-a-ninja-build-with-xcode).
240-
There is also a third option, which is somewhat more involved:
241-
[using both Ninja and Xcode](#using-both-ninja-and-xcode).
242-
3. Build the toolchain with optimizations, debuginfo, and assertions and run
243-
the tests.
233+
2. Build the toolchain with optimizations, debuginfo, and assertions, using
234+
Ninja.
244235
- macOS:
245-
- Via Ninja:
246-
```sh
247-
utils/build-script --skip-build-benchmarks \
248-
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
249-
--sccache --release-debuginfo --swift-disable-dead-stripping
250-
```
251-
- Via Xcode:
252-
```sh
253-
utils/build-script --skip-build-benchmarks \
254-
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
255-
--sccache --release-debuginfo --swift-disable-dead-stripping \
256-
--xcode
257-
```
258-
- Linux (uses Ninja):
236+
```sh
237+
utils/build-script --skip-build-benchmarks \
238+
--skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
239+
--sccache --release-debuginfo --swift-disable-dead-stripping
240+
```
241+
- Linux:
259242
```sh
260243
utils/build-script --release-debuginfo --skip-early-swift-driver \
261244
--skip-early-swiftsyntax
262245
```
263-
This will create a directory
264-
`swift-project/build/Ninja-RelWithDebInfoAssert`
265-
(with `Xcode` instead of `Ninja` if you used `--xcode`)
246+
This will create a directory `swift-project/build/Ninja-RelWithDebInfoAssert`
266247
containing the Swift compiler and standard library and clang/LLVM build artifacts.
267248
If the build fails, see [Troubleshooting build issues](#troubleshooting-build-issues).
268249

@@ -340,31 +321,21 @@ git checkout -b my-branch
340321
git push --set-upstream my-remote my-branch
341322
```
342323
343-
### First time Xcode setup
344-
345-
If you used `--xcode` earlier, you will see an Xcode project generated under
346-
`../build/Xcode-RelWithDebInfoAssert/swift-macosx-x86_64` (or
347-
`../build/Xcode-RelWithDebInfoAssert/swift-macosx-arm64` on Apple Silicon Macs). When you open the
348-
project, Xcode might helpfully suggest "Automatically Create Schemes". Most of
349-
those schemes are not required in day-to-day work, so you can instead manually
350-
select the following schemes:
351-
- `swift-frontend`: If you will be working on the compiler.
352-
- `check-swift-all`: This can be used to run the tests. The test runner does
353-
not integrate with Xcode though, so it may be easier to run tests directly
354-
on the command line for more fine-grained control over which exact tests are
355-
run.
356-
<!-- TODO: Insert SourceKit/stdlib specific instructions? -->
324+
<!-- TODO: Insert paragraph about the main Ninja targets. -->
325+
357326
327+
<!--
328+
Note: utils/build-script contains a link to this heading that needs an update
329+
whenever the heading is modified.
330+
-->
358331
### Using Ninja with Xcode
359332
360-
Although it's possible to build the toolchain entirely with Xcode via `--xcode`,
361-
a more efficient and robust option is to integrate a Ninja build with Xcode.
362-
This is also convenient in that you can navigate, build, run, edit, and debug in
363-
Xcode while retaining the option of using Ninja on the command line.
333+
This workflow enables you to navigate, edit, build, run, and debug in Xcode
334+
while retaining the option of building with Ninja on the command line.
364335
365336
Assuming that you have already [built the toolchain via Ninja](#the-actual-build),
366337
several more steps are necessary to set up this environment:
367-
* Generate Xcode projects with `utils/build-script --skip-build --xcode --skip-early-swift-driver`.
338+
* Generate Xcode projects with `utils/build-script --xcode --swift-darwin-supported-archs "$(uname -m)"`.
368339
This will first build a few LLVM files that are needed to configure the
369340
projects.
370341
* Create a new Xcode workspace.
@@ -401,7 +372,7 @@ several more steps are necessary to set up this environment:
401372
* _Directory_ to the path of the build directory associated with the Ninja
402373
target. For Swift targets, including the standard library and runtime, you
403374
want `path/to/swift-project/build/Ninja-*/swift-macosx-*`
404-
* Add a scheme for the target. Be sure not to select a target from one the
375+
* Add a scheme for the target. Be careful not to select a target from one of the
405376
generated Xcode projects.
406377
* > **Note**
407378
> Ignore this step if the target associates to a non-executable Ninja target
@@ -477,11 +448,6 @@ To rebuild everything, including the standard library:
477448
ninja -C ../build/Ninja-RelWithDebInfoAssert/swift-macosx-$(uname -m)
478449
```
479450

480-
### Incremental builds with Xcode
481-
482-
Rebuilding works the same way as with any other Xcode project; you can use
483-
<kbd>⌘</kbd>+<kbd>B</kbd> or Product → Build.
484-
485451
### Spot checking an incremental build
486452

487453
As a quick test, go to `lib/Basic/Version.cpp` and tweak the version
@@ -556,13 +522,12 @@ There are two main ways to run tests:
556522

557523
If you are making small changes to the compiler or some other component, you'll
558524
likely want to [incrementally rebuild](#editing-code) only the relevant
559-
Ninja/Xcode target and use `lit.py` with `--filter`. One potential failure
560-
mode with this approach is accidental use of stale binaries. For example, say
561-
that you want to rerun a SourceKit test but you only incrementally rebuilt the
562-
compiler. Then your changes will not be reflected when the test runs because the
563-
`sourcekitd` binary was not rebuilt. Using `run-test` instead is the safer
564-
option, but it will lead to a longer feedback loop due to more things getting
565-
rebuilt.
525+
target and use `lit.py` with `--filter`. One potential failure mode with this
526+
approach is accidental use of stale binaries. For example, say that you want to
527+
rerun a SourceKit test but you only incrementally rebuilt the compiler. Then
528+
your changes will not be reflected when the test runs because the `sourcekitd`
529+
binary was not rebuilt. Using `run-test` instead is the safer option, but it
530+
will lead to a longer feedback loop due to more things getting rebuilt.
566531
567532
In the rare event that a local test failure happens to be unrelated to your
568533
changes (is not due to stale binaries and reproduces without your changes),

0 commit comments

Comments
 (0)