-
Notifications
You must be signed in to change notification settings - Fork 232
First pass at the new Getting Started page #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kaishin
merged 2 commits into
swiftlang:content-improvements
from
kaishin:content-improvements
Dec 20, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
@import "pages/getting-started"; | ||
@import "pages/swift-evolution"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
.guide-list { | ||
list-style: none; | ||
padding-left: 0; | ||
} | ||
|
||
.use-case-list { | ||
list-style: none; | ||
padding-left: 0; | ||
display: grid; | ||
gap: 1rem; | ||
|
||
.use-case { | ||
border: 1px solid var(--color-fill-gray); | ||
padding: 0 1rem; | ||
border-radius: 4px; | ||
display: flex; | ||
flex-direction: column; | ||
|
||
h3 { | ||
line-height: 1.4; | ||
font-size: 1.4rem; | ||
} | ||
|
||
p { | ||
flex-grow: 1; | ||
color: var(--color-secondary-label); | ||
} | ||
} | ||
|
||
@media (min-width: 1000px) { | ||
grid-template-columns: repeat(3, 1fr); | ||
} | ||
} | ||
|
||
a.cta-secondary { | ||
border-radius: var(--border-radius); | ||
border: 1px solid var(--color-text); | ||
color: var(--color-text); | ||
display: block; | ||
margin: 1rem 0; | ||
padding: .5rem 0; | ||
text-align: center; | ||
|
||
&:hover { | ||
background-color: var(--color-text); | ||
color: var(--color-fill); | ||
text-decoration: none; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## Go Further | ||
|
||
Ready to dive deeper? Here are some hand-picked resources covering about various Swift features and use. | ||
|
||
<ul class="guide-list"> | ||
<li class="guide"> | ||
<h3>Concurrency</h3> | ||
<p class="description"> | ||
When you have code that needs to run at the same time as other code, it's important to choose the right tool for the job. | ||
</p> | ||
|
||
<p class="description"> | ||
We'll take you through the different kinds of concurrent tasks you can create in Swift, show you how to create groups of tasks, and find out how to cancel tasks in progress. We'll also provide guidance on when you may want to use unstructured tasks. | ||
</p> | ||
|
||
<div class="links links-list-nostyle"> | ||
<a href="/">Read guide</a> | ||
</div> | ||
</li> | ||
|
||
<li class="guide"> | ||
<h3>Testing</h3> | ||
<p class="description"> | ||
Unit testing is an essential tool to consistently verify your code works correctly. Learn about the built-in testing features in Xcode, using XCTest. | ||
</p> | ||
|
||
<p class="description"> | ||
Find out how to organize your tests and run them under different configurations using test plans, and discover how to automate testing and efficiently work with the results. | ||
</p> | ||
|
||
<div class="links links-list-nostyle"> | ||
<a href="/">Read guide</a> | ||
</div> | ||
</li> | ||
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,174 +1,12 @@ | ||
## Installing Swift | ||
|
||
The first step to using Swift is to download and install | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tomerd I pieced the install section from other concepts but your input here would be very valuable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @shahmishal |
||
the compiler and other required components. | ||
Go to the [Download](/download) page | ||
and follow the instructions for your target platform. | ||
If you don't have Swift installed, [install it first](/install). To test that you have Swift installed, run `swift --version` in the terminal. | ||
|
||
In order to follow along with the examples below, | ||
make sure to add Swift to your `$PATH`. | ||
### Swift Package Manager | ||
|
||
### On macOS | ||
When you install Swift you’ll also get the latest stable version of the Swift build tool and package manager, also known as Swift Package Manager, or SwiftPM . | ||
|
||
The default location for the downloadable toolchain on macOS is | ||
`/Library/Developer/Toolchains`. | ||
You can make the latest installed toolchain available for use from the terminal with the following command: | ||
|
||
~~~ shell | ||
$ export TOOLCHAINS=swift | ||
~~~ | ||
|
||
To select any other installed toolchain, use its identifier in the `TOOLCHAINS` | ||
variable. The identifier can be found in toolchain's `Info.plist` file. | ||
|
||
~~~ shell | ||
$ /usr/libexec/PlistBuddy -c "Print CFBundleIdentifier:" /Library/Developer/Toolchains/swift-4.0-RELEASE.xctoolchain/Info.plist | ||
org.swift.4020170919 | ||
|
||
$ export TOOLCHAINS=org.swift.4020170919 | ||
~~~ | ||
|
||
### On Linux | ||
|
||
0. Install required dependencies: | ||
|
||
{% include linux/table.html %} | ||
|
||
If you installed the Swift toolchain on Linux | ||
to a directory other than the system root, | ||
you will need to run the following command, | ||
using the actual path of your Swift installation: | ||
|
||
~~~ shell | ||
$ export PATH=/path/to/Swift/usr/bin:"${PATH}" | ||
~~~ | ||
|
||
### On Windows | ||
|
||
#### Dependencies | ||
|
||
Swift has the following general dependencies: | ||
|
||
- Git (used by Swift Package Manager) | ||
|
||
- Python[^1] (used by the debugger - lldb) | ||
|
||
[^1]: The windows binaries are built against Python 3.10.2 | ||
|
||
Windows has the following additional platform specific dependencies: | ||
|
||
- Windows SDK (provides the Windows headers and import libraries) | ||
|
||
- Visual Studio (provides the Visual C++ SDK/Build Tools for additional headers) | ||
|
||
#### Enabling Developer Mode | ||
|
||
In order to develop applications, particularly with the Swift Package Manager, you will need to enable developer mode. Please see Microsoft's [documentation](https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development) for instructions for enabling developer mode. | ||
|
||
#### Installation Instructions | ||
|
||
##### Install using the Windows Package Manager | ||
|
||
The [Windows Package Manager](https://docs.microsoft.com/windows/package-manager/) can be found in the [App Store](https://www.microsoft.com/en-us/p/app-installer/9nblggh4nns1) or be [installed directly](ms-appinstaller:?source=https://aka.ms/getwinget). | ||
|
||
0. Install required dependencies: | ||
|
||
The platform dependencies cannot be installed through the Windows Package Manager as the install rules do not install the components necessary. They will be installed through Visual Studio installer. | ||
|
||
~~~ cmd | ||
winget install Git.Git | ||
winget install Python.Python.3 --version 3.10.2150.0 | ||
|
||
curl -sOL https://aka.ms/vs/16/release/vs_community.exe | ||
start /w vs_community.exe --passive --wait --norestart --nocache ^ | ||
--installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community" ^ | ||
--add Microsoft.VisualStudio.Component.Windows10SDK.19041 ^ | ||
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 | ||
del /q vs_community.exe | ||
~~~ | ||
|
||
Start up a new Command Prompt and install the Python library six. | ||
|
||
~~~ cmd | ||
pip install six | ||
~~~ | ||
|
||
0. Install Swift: | ||
|
||
Swift can be installed through the official installer directly, or using the Windows Package Manager as well. Notice that Windows Package Manager release may be behind the official release. | ||
|
||
* Using the official installer: | ||
1. Download the [latest package release](/download). | ||
1. Run the package installer. | ||
|
||
* Using the Windows Package Manager: | ||
~~~ cmd | ||
winget install Swift.Toolchain | ||
~~~ | ||
|
||
A Swift toolchain will be installed at `%SystemDrive%\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain`. A compatible Swift SDK will be installed at `%SystemDrive%\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk`. | ||
|
||
##### Traditional Installation | ||
|
||
> **NOTE:** The traditional installation process is required for Swift older than 5.4.2. | ||
|
||
Swift has been tested with [Visual Studio 2019](https://visualstudio.microsoft.com). You will need to install Visual Studio with the following components. The installer for Swift is available in the [Download](/download) section. The toolchain on Windows is installed to `%SystemDrive%\Library\Developer\Toolchains`. | ||
|
||
The following Visual Studio components are **required**: | ||
|
||
| Component | Visual Studio ID | | ||
|-----------|------------------| | ||
| MSVC v142 - VS 2019 C++ x64/x86 build tools (Latest) | Microsoft.VisualStudio.Component.VC.Tools.x86.x64 | | ||
| Windows 10 SDK (10.0.17763.0)[^2] | Microsoft.VisualStudio.Component.Windows10SDK.17763 | | ||
|
||
[^2]: You may install a newer SDK instead. | ||
|
||
The following additional Visual Studio components are **recommended**: | ||
|
||
| Component | Visual Studio ID | | ||
|-----------|------------------| | ||
| Git for Windows | Microsoft.VisualStudio.Component.Git | | ||
| Python 3 64-bit (3.7.8) | Component.CPython.x64 | | ||
|
||
The following additional Visual Studio component is **suggested**: | ||
|
||
| Component | Visual Studio ID | | ||
|-----------|------------------| | ||
| C++ CMake tools for Windows | Microsoft.VisualStudio.Component.VC.CMake.Project | | ||
|
||
##### Support Files | ||
|
||
> **NOTE:** This is only required for versions older than 5.4.2 | ||
|
||
You must use the `x64 Native Tools for VS2019 Command Prompt` to run the following steps. The `x64 Native Tools for VS2019 Command Prompt` runs the `DevEnv` script from Visual Studio that sets up the necessary environment variables to find the system headers. | ||
|
||
In order to make the Windows SDK accessible to Swift, it is necessary to deploy a few files into the Windows SDK. The following will modify your Visual Studio Installation, and as such will require to be run from an (elevated) "Administrator" `x86 Native Tools for VS2019 Command Prompt`. | ||
|
||
~~~ cmd | ||
copy /Y %SDKROOT%\usr\share\ucrt.modulemap "%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt\module.modulemap" | ||
copy /Y %SDKROOT%\usr\share\visualc.modulemap "%VCToolsInstallDir%\include\module.modulemap" | ||
copy /Y %SDKROOT%\usr\share\visualc.apinotes "%VCToolsInstallDir%\include\visualc.apinotes" | ||
copy /Y %SDKROOT%\usr\share\winsdk.modulemap "%UniversalCRTSdkDir%\Include\%UCRTVersion%\um\module.modulemap" | ||
~~~ | ||
|
||
Because it is installing the files into the Visual Studio image, the files will need to be copied each time Visual Studio is updated. | ||
|
||
##### Repairing after Visual Studio Updates | ||
|
||
If Visual Studio is updated, you may have to repair the installation. See Microsoft's [instructions](https://support.microsoft.com/en-us/windows/repair-apps-and-programs-in-windows-10-e90eefe4-d0a2-7c1b-dd59-949a9030f317) for repairing installed programs. | ||
|
||
* * * | ||
|
||
### Swift Version | ||
|
||
You can verify that you are running the expected version of Swift | ||
by entering the `swift` command and passing the `--version` flag: | ||
|
||
~~~ shell | ||
$ swift --version | ||
Apple Swift version 2.2-dev (LLVM ..., Clang ..., Swift ...) | ||
~~~ | ||
|
||
The `-dev` suffix on the version number | ||
is used to indicate that it's a *development* build, | ||
not a released version. | ||
SwiftPM does lots of things: | ||
- Build your project with `swift build`. | ||
- Test your project with `swift test`. | ||
- Run your project with `swift run`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Using Swift | ||
|
||
Below are some examples of the many use cases of Swift. | ||
|
||
<ul class="use-case-list"> | ||
<li class="use-case"> | ||
<h3>Build a Web Server (Vapor)</h3> | ||
<p class="description"> | ||
Use the open-source Vapor framework to build a web API entirely with Swift. | ||
Requires macOS or Linux. | ||
</p> | ||
|
||
<a href="/getting-started/vapor-web-server" class="cta-secondary">Start tutorial</a> | ||
</li> | ||
|
||
<li class="use-case"> | ||
<h3>Build a Command-line Tool</h3> | ||
<p class="description"> | ||
Build a command-line tool using Swift and SwiftPM. | ||
</p> | ||
|
||
<a href="/getting-started/cli-tool" class="cta-secondary">Start tutorial</a> | ||
</li> | ||
|
||
<li class="use-case"> | ||
<h3>Build an app for Apple platforms</h3> | ||
<p class="description"> | ||
Use Swift and SwiftUI to build an app that works on iOS and macOS. | ||
Requires macOS 12 and Xcode 14. | ||
</p> | ||
|
||
<a href="/" class="cta-secondary">Start tutorial</a> | ||
</li> | ||
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
layout: page | ||
title: Build a Command-line Tool | ||
--- | ||
|
||
TODO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
layout: page | ||
title: Build a Web Server | ||
--- | ||
|
||
TODO |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.