@@ -21,44 +21,60 @@ features like flow control, data structures, and functions, with high-level
21
21
constructs like objects, protocols, closures, and generics. Swift embraces
22
22
modules, eliminating the need for headers and the code duplication they entail.
23
23
24
+ To learn more about the programming language, visit [ swift.org] ( https://swift.org/documentation/ ) .
24
25
25
- ## Documentation
26
-
27
- To read the documentation, start by installing the
28
- [ Sphinx] ( http://sphinx-doc.org ) documentation generator tool by running the command:
29
-
30
- ` easy_install -U Sphinx `
31
-
32
- Once complete, you can build the Swift documentation by changing directory into
33
- [ docs] ( https://github.com/apple/swift/tree/master/docs ) and typing ` make ` . This
34
- compiles the ` .rst ` files in the [ docs] ( https://github.com/apple/swift/tree/master/docs )
35
- directory into HTML in the ` docs/_build/html ` directory.
26
+ ## Contributing to Swift
36
27
37
- Many of the docs are out of date, but you can see some historical design
38
- documents in the ` docs ` directory .
28
+ Contributions to Swift are welcomed and encouraged! Please see the
29
+ [ Contributing to Swift guide ] ( https://swift.org/contributing/ ) .
39
30
40
- Another source of documentation is the standard library itself, located in
41
- ` stdlib ` . Much of the language is actually implemented in the library
42
- (including ` Int ` ), and the standard library gives some examples of what can be
43
- expressed today.
31
+ To be a truly great community, [ Swift.org] ( https://swift.org/ ) needs to welcome
32
+ developers from all walks of life, with different backgrounds, and with a wide
33
+ range of experience. A diverse and friendly community will have more great
34
+ ideas, more unique perspectives, and produce more great code. We will work
35
+ diligently to make the Swift community welcoming to everyone.
44
36
37
+ To give clarity of what is expected of our members, Swift has adopted the
38
+ code of conduct defined by the Contributor Covenant. This document is used
39
+ across many open source communities, and we think it articulates our values
40
+ well. For more, see the [ Code of Conduct] ( https://swift.org/community/#code-of-conduct ) .
45
41
46
42
## Getting Started
47
43
48
- These instructions give the most direct path to a working Swift
49
- development environment. Options for doing things differently are
50
- discussed below.
44
+ These instructions give the most direct path to a working Swift development
45
+ environment. To build from source you will need 2 GB of disk space for the
46
+ source code and over 20 GB of disk space for the build artifacts. A clean
47
+ build can take multiple hours, but incremental builds will finish much faster.
51
48
52
49
53
50
### System Requirements
54
51
55
52
macOS, Ubuntu Linux LTS, and the latest Ubuntu Linux release are the current
56
53
supported host development operating systems.
57
54
58
- For macOS, you need [ Xcode 9.0 beta 4] ( https://developer.apple.com/xcode/downloads/ ) .
55
+ #### macOS
56
+
57
+ To build for macOS, you need [ Xcode 9.0 beta 4] ( https://developer.apple.com/xcode/downloads/ ) .
58
+ The required version of Xcode changes frequently, and is often a beta release.
59
+ Check this document or the host information on < https://ci.swift.org > for the
60
+ current required version.
61
+
62
+ You will also need [ CMake] ( https://cmake.org ) and [ Ninja] ( https://ninja-build.org ) ,
63
+ which can be installed via a package manager:
64
+
65
+ ** [ Homebrew] ( https://brew.sh/ ) **
66
+
67
+ brew install cmake ninja
68
+
69
+ ** [ MacPorts] ( https://macports.org ) **
70
+
71
+ sudo port install cmake ninja
72
+
73
+ Instructions for installing CMake and Ninja directly can be found [ below] ( #build-dependencies )
74
+
75
+ #### Linux
59
76
60
- <a name =" linux-dependencies " ></a >For Ubuntu, you'll need the following
61
- development dependencies:
77
+ For Ubuntu, you'll need the following development dependencies:
62
78
63
79
sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev autoconf libtool systemtap-sdt-dev tzdata
64
80
@@ -91,97 +107,168 @@ cloning over SSH may provide a better experience (which requires
91
107
git clone git@github.com:apple/swift.git
92
108
./swift/utils/update-checkout --clone-with-ssh
93
109
94
- #### CMake
95
- [ CMake] ( https://cmake.org ) is the core infrastructure used to configure builds of
96
- Swift and its companion projects; at least version 3.4.3 is required.
110
+ ### Building Swift
97
111
98
- On macOS, you can download the [ CMake Binary Distribution ] ( https://cmake.org/download ) ,
99
- bundled as an application, copy it to ` /Applications ` , and add the embedded
100
- command line tools to your ` PATH ` :
112
+ The ` build-script ` is a high-level build automation script that supports basic
113
+ options such as building a Swift-compatible LLDB, building the Swift Package
114
+ Manager, building for various platforms, running tests after builds, and more.
101
115
102
- export PATH=/Applications/CMake.app/Contents/bin:$PATH
103
-
104
- On Linux, if you have not already installed Swift's [ development
105
- dependencies] ( #linux-dependencies ) , you can download and install the CMake
106
- package separately using the following command:
116
+ There are two primary build systems to use: Xcode and Ninja. The Xcode build
117
+ system allows you to work in Xcode.app, but Ninja is a bit faster and supports
118
+ more environments.
107
119
108
- sudo apt-get install cmake
109
-
120
+ To build using Ninja, run:
110
121
111
- #### Ninja
112
- [ Ninja] ( https://ninja-build.org ) is the current recommended build system
113
- for building Swift and is the default configuration generated by CMake. [ Pre-built
114
- packages] ( https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages )
115
- are available for macOS and Linux distributions. You can also clone Ninja
116
- next to the other projects and it will be bootstrapped automatically:
122
+ utils/build-script --release-debuginfo
117
123
118
- ** Via HTTPS**
124
+ When developing Swift, it helps to build what you're working on in a debug
125
+ configuration while building the rest of the project with optimizations. Below
126
+ are some examples of using debug variants:
119
127
120
- git clone https://github.com/ninja-build/ninja.git && cd ninja
121
- git checkout release
122
- cat README
128
+ utils/build-script --release-debuginfo --debug-swift # Swift frontend built in debug
129
+ utils/build-script -- release-debuginfo --debug-swift-stdlib # Standard library built in debug
130
+ utils/build-script --release-debuginfo --debug-swift --force-optimized-typechecker # Swift frontend sans type checker built in debug
123
131
124
- ** Via SSH**
132
+ Limiting the amount of debug code in the compiler has a very large impact on
133
+ Swift compile times, and in turn the test execution time. If you want to build
134
+ the entire project in debug, you can run:
125
135
126
- git clone git@github.com:ninja-build/ninja.git && cd ninja
127
- git checkout release
128
- cat README
136
+ utils/build-script --debug
129
137
130
- #### Install via third-party packaging tool (macOS only)
138
+ For documentation of all available arguments, as well as additional usage
139
+ information, see the inline help:
131
140
132
- ** [ Homebrew ] ( https://brew.sh/ ) **
141
+ utils/build-script -h
133
142
134
- brew install cmake ninja
143
+ #### Xcode
135
144
136
- ** [ MacPorts] ( https://macports.org ) **
145
+ To build using Xcode, specify the ` --xcode ` argument on any of the above commands.
146
+ Xcode.app can be used to edit the Swift source code, but it is not currently
147
+ fully supported as a build environment for SDKs other than macOS. The generated
148
+ Xcode project does not integrate with the test runner, but the tests can be run
149
+ with the 'check-swift' target.
137
150
138
- sudo port install cmake ninja
151
+ #### Build Products
139
152
140
- ### Building Swift
153
+ All of the build products are placed in ` swift-source/build/${TOOL}-${MODE}/${PRODUCT}-${PLATFORM}/ ` .
154
+ If macOS Swift with Ninja in DebugAssert mode was built, all of the products
155
+ would be in ` swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/ ` . It
156
+ helps to save this directory as an environment variable for future use.
141
157
142
- The ` build-script ` is a high-level build automation script that supports basic
143
- options such as building a Swift-compatible LLDB, building the Swift Package
144
- Manager, building for iOS, running tests after builds, and more. It also
145
- supports presets, which you can define for common combinations of build options.
158
+ export SWIFT_BUILD_DIR="~/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64"
146
159
147
- To find out more:
160
+ #### Ninja
148
161
149
- utils/build-script -h
162
+ Once the first build has completed, ninja can perform fast incremental builds of
163
+ various products. These incremental builds are a big timesaver when developing
164
+ and debugging.
165
+
166
+ cd ${SWIFT_BUILD_DIR}
167
+ ninja swift
168
+
169
+ This will build the Swift compiler, but will not rebuild the standard library or
170
+ any other target. Building the ` swift-stdlib ` target as an additional layer of
171
+ testing from time to time is also a good idea. To build just the standard
172
+ library, run:
173
+
174
+ ninja swift-stdlib
175
+
176
+ It is always a good idea to do a full build after using ` update-checkout ` .
177
+
178
+ #### Using Xcode
179
+
180
+ To open the Swift project in Xcode, open ` ${SWIFT_BUILD_DIR}/Swift.xcodeproj ` .
181
+ It will auto-create a * lot* of schemes for all of the available targets. A
182
+ common debug flow would involve:
150
183
151
- Note: Arguments after "--" above are forwarded to ` build-script-impl ` , which is
152
- the ultimate shell script that invokes the actual build and test commands.
184
+ - Select the 'swift' scheme
185
+ - Pull up the scheme editor (⌘⇧<)
186
+ - Select the 'Arguments' tab and click the '+'
187
+ - Add the command line options
188
+ - Close the scheme editor
189
+ - Build and run
153
190
154
- A basic command to build Swift with optimizations and run basic tests with
155
- Ninja:
191
+ Another option is to change the scheme to "Wait for executable to be launched",
192
+ then run the build product in Terminal.
156
193
157
- utils/build-script -r -t
194
+ ### Build Failures
158
195
159
- ## Developing Swift in Xcode
196
+ Make sure you are using the [ correct release ] ( #macos ) of Xcode.
160
197
161
- ` build-script ` can also generate Xcode projects:
198
+ If you have changed Xcode versions but still encounter errors that appear to
199
+ be related to the Xcode version, try passing ` --rebuild ` to ` build-script ` .
162
200
163
- utils/build-script -x
201
+ When a new version of Xcode is released, you can update your build without
202
+ recompiling the entire project by passing the ` --reconfigure ` option.
164
203
165
- The Xcode IDE can be used to edit the Swift source code, but it is not currently
166
- fully supported as a build environment for SDKs other than macOS. If you need to
167
- work with other SDKs, you'll need to create a second build using Ninja.
204
+ Make sure all repositories are up to date with the ` update-checkout ` command
205
+ described above.
168
206
169
207
## Testing Swift
170
208
171
- See [ docs/Testing.md] ( docs/Testing.md ) .
209
+ See [ docs/Testing.md] ( docs/Testing.md ) , in particular the section on [ lit.py ] ( docs/Testing.md#using-litpy ) .
172
210
173
- ## Contributing to Swift
211
+ ## Learning More
174
212
175
- Contributions to Swift are welcomed and encouraged! Please see the
176
- [ Contributing to Swift guide] ( https://swift.org/contributing/ ) .
213
+ Be sure to look through the [ docs/] docs directory for more information about the
214
+ compiler. In particular, the document on [ Debugging The Compiler] ( docs/DebuggingTheCompiler.rst ) ,
215
+ and [ Continuous Integration.md] ( docs/ContinuousIntegration.md ) are very helpful
216
+ to understand before submitting your first PR.
177
217
178
- To be a truly great community, [ Swift.org] ( https://swift.org/ ) needs to welcome
179
- developers from all walks of life, with different backgrounds, and with a wide
180
- range of experience. A diverse and friendly community will have more great
181
- ideas, more unique perspectives, and produce more great code. We will work
182
- diligently to make the Swift community welcoming to everyone.
218
+ ### Building Documentation
183
219
184
- To give clarity of what is expected of our members, Swift has adopted the
185
- code of conduct defined by the Contributor Covenant. This document is used
186
- across many open source communities, and we think it articulates our values
187
- well. For more, see the [ Code of Conduct] ( https://swift.org/community/#code-of-conduct ) .
220
+ To read the compiler documentation, start by installing the
221
+ [ Sphinx] ( http://sphinx-doc.org ) documentation generator tool by running the command:
222
+
223
+ ` easy_install -U Sphinx `
224
+
225
+ Once complete, you can build the Swift documentation by changing directory into
226
+ [ docs] ( https://github.com/apple/swift/tree/master/docs ) and typing ` make ` . This
227
+ compiles the ` .rst ` files in the [ docs] ( https://github.com/apple/swift/tree/master/docs )
228
+ directory into HTML in the ` docs/_build/html ` directory.
229
+
230
+ Many of the docs are out of date, but you can see some historical design
231
+ documents in the ` docs ` directory.
232
+
233
+ Another source of documentation is the standard library itself, located in
234
+ ` stdlib ` . Much of the language is actually implemented in the library
235
+ (including ` Int ` ), and the standard library gives some examples of what can be
236
+ expressed today.
237
+
238
+ ## Build Dependencies
239
+
240
+ ### CMake
241
+ [ CMake] ( https://cmake.org ) is the core infrastructure used to configure builds of
242
+ Swift and its companion projects; at least version 3.4.3 is required.
243
+
244
+ On macOS, you can download the [ CMake Binary Distribution] ( https://cmake.org/download ) ,
245
+ bundled as an application, copy it to ` /Applications ` , and add the embedded
246
+ command line tools to your ` PATH ` :
247
+
248
+ export PATH=/Applications/CMake.app/Contents/bin:$PATH
249
+
250
+ On Linux, if you have not already installed Swift's [ development
251
+ dependencies] ( #linux ) , you can download and install the CMake
252
+ package separately using the following command:
253
+
254
+ sudo apt-get install cmake
255
+
256
+
257
+ ### Ninja
258
+ [ Ninja] ( https://ninja-build.org ) is the current recommended build system
259
+ for building Swift and is the default configuration generated by CMake. [ Pre-built
260
+ packages] ( https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages )
261
+ are available for macOS and Linux distributions. You can also clone Ninja
262
+ next to the other projects and it will be bootstrapped automatically:
263
+
264
+ ** Via HTTPS**
265
+
266
+ git clone https://github.com/ninja-build/ninja.git && cd ninja
267
+ git checkout release
268
+ cat README
269
+
270
+ ** Via SSH**
271
+
272
+ git clone git@github.com:ninja-build/ninja.git && cd ninja
273
+ git checkout release
274
+ cat README
0 commit comments