You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although it's possible to build the swift compiler entirely with Xcode (`--xcode`), often it's better to build with _ninja_ and use Xcode for editing and debugging.
106
-
This is very convenient because you get the benefits of the ninja build system and all the benefits of the Xcode IDE, like code completion, refactoring, debugging, etc.
107
-
108
-
To setup this environment a few steps are necessary:
109
-
* Create a new workspace.
110
-
* Create Xcode projects for LLVM and Swift with `utils/build-script --skip-build --xcode --skip-early-swift-driver`. Beside configuring, this needs to build a few LLVM files which are needed to configure the swift project.
111
-
* Add the generated LLVM and Swift projects to your workspace. They can be found in the build directories `build/Xcode-DebugAssert/llvm-macosx-x86_64/LLVM.xcodeproj` and `build/Xcode-DebugAssert/swift-macosx-x86_64/Swift.xcodeproj`.
112
-
* Add the `swift/SwiftCompilerSources` package to the workspace.
113
-
* Create a new empty project `build-targets` (or however you want to name it) in the workspace, using the "External Build System" template.
114
-
* For each compiler tool you want to build (`swift-frontend`, `sil-opt`, etc.), add an "External Build System" target to the `build-targets` project.
115
-
* In the "Info" section of the target configuration, set:
116
-
* the _Build Tool_ to the full path of the `ninja` command
117
-
* the _Argument_ to the tool name (e.g. `swift-frontend`)
118
-
* the _Directory_ to the ninja swift build directory, e.g. `/absolute/path/to/build/Ninja-DebugAssert/swift-macosx-x86_64`. For debugging to work, this has to be a debug build of course.
119
-
* For each target, create a new scheme:
120
-
* In the _Build_ section add the corresponding build target that you created before.
121
-
* In the _Run/Info_ section select the built _Executable_ in the build directory (e.g. `/absolute/path/to/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift-frontend`).
122
-
* In the _Run/Arguments_ section you can set the command line arguments with which you want to run the compiler tool.
123
-
* In the _Run/Options_ section you can set the working directory for debugging.
124
-
125
-
Now you are all set. You can build and debug like with a native Xcode project.
126
-
127
-
If the project structure changes, e.g. new source files are added or deleted, you just have to re-create the LLVM and Swift projects with `utils/build-script --skip-build --xcode --skip-early-swift-driver`.
103
+
## Using Ninja with Xcode
104
+
105
+
Although it's possible to build the toolchain entirely with Xcode via `--xcode`,
106
+
a more efficient and robust option is to integrate a Ninja build with Xcode.
107
+
This is also convenient in that you can navigate, build, run, edit and debug in
108
+
Xcode while retaining the option of using Ninja on the command line.
109
+
110
+
Assuming that you have already [built the toolchain via Ninja](#the-actual-build),
111
+
several more steps are necessary to set up this environment:
112
+
* Generate Xcode projects with `utils/build-script --skip-build --xcode --skip-early-swift-driver`.
113
+
This will first build a few LLVM files that are needed to configure the
114
+
projects.
115
+
* Create a new Xcode workspace.
116
+
* Add the generated Xcode projects or Swift packages that are relevant to your
117
+
tasks to your workspace. All the Xcode projects can be found among the
118
+
build artifacts in `build/Xcode-DebugAssert`. For example:
119
+
* If you are aiming for the compiler, add `build/Xcode-DebugAssert/swift-macosx-*/Swift.xcodeproj`.
120
+
This project also includes the standard library and runtime sources. If you
121
+
need the parts of the compiler that are implemented in Swift itself, add the
122
+
`swift/SwiftCompilerSources/Package.swift` package as well.
123
+
* If you are aiming for just the standard library or runtime, add
0 commit comments