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
Update documentation and online help around global default toolchains (#224)
Update documentation and online help to add more clarity about the global default and in-use toolchains
Skip prompting to update an existing swift version file
Add more informative messages when using toolchains to indicate what actually changed
If no toolchain is provided, the currently in-use toolchain will be printed, if any:
179
+
If no toolchain is provided, the currently in-use toolchain will be printed, if any. This is based on the current working directory and `.swift-version` files if one is present. If the in-use toolchain is also the global default then it will be shown as the default.
Copy file name to clipboardExpand all lines: Documentation/SwiftlyDocs.docc/use-toolchains.md
+38-4Lines changed: 38 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ When you install a toolchain you can start using it right away. If you don't hav
9
9
```
10
10
$ swiftly install latest
11
11
$ swift --version
12
-
Swift version 6.0.1 (swift-6.0.1-RELEASE)
12
+
Swift version 6.0.3 (swift-6.0.3-RELEASE)
13
13
Target: aarch64-unknown-linux-gnu
14
14
$ swift build # Build with the current toolchain
15
15
```
@@ -27,11 +27,18 @@ $ swift build # Builds with the latest snapshot toolchain on the main branch
27
27
$ lldb # Run the debugger from the latest snapshot toolchain
28
28
```
29
29
30
+
The use command doesn't require a full version. It is sufficient to provide just a major version, or the major and minor versions. Swiftly will use the newest matching version that you have installed, if any.
31
+
32
+
```
33
+
$ swiftly use 5
34
+
swift --version # Version matches the 5.10.1 toolchain that was installed above
35
+
```
36
+
30
37
If you're not certain which toolchain is in-use then use the bare `swiftly use` command to provide details:
31
38
32
39
```
33
40
$ swiftly use
34
-
Swift 6.0.1 (default)
41
+
Swift 5.10.1 (default)
35
42
```
36
43
37
44
You can print the exact toolchain location with the `--print-location` flag:
@@ -54,7 +61,7 @@ $ cat .swift-version
54
61
6.0.1
55
62
```
56
63
57
-
When a team member uses swiftly with this git repository it can use the correct toolchain version automatically:
64
+
When a team member uses swiftly with this git repository the toolchain that is in use matches the version in the file.
58
65
59
66
```
60
67
$ cd path/to/git/repository
@@ -63,7 +70,7 @@ Swift version 6.0.1 (swift-6.0.1-RELEASE)
63
70
Target: aarch64-unknown-linux-gnu
64
71
```
65
72
66
-
If that team member doesn't have the toolchain installed on their system there will be a warning. They can install the selected toolchain automatically like this:
73
+
If that team member doesn't have the toolchain installed on their system there will be an error. They can install the selected toolchain automatically like this:
67
74
68
75
```
69
76
$ cd path/to/git/repository
@@ -77,3 +84,30 @@ $ swiftly run swift build +main-snapshot
77
84
```
78
85
79
86
> Note: The toolchain must be installed on your system before you can run with it.
87
+
88
+
The `.swift version` file, if it is present in your working directory (or parent) will select the toolchain that is in use. If you are working in a directory that doesn't have this file, then you can set a global default toolchain to use in these places.
89
+
90
+
```
91
+
$ swiftly use --global-default 6.0.1
92
+
```
93
+
94
+
Here the `--global-default` flag ensures that the default is set globally to the "6.0.1" toolchain whenever there isn't a swift version file, and there isn't a version specified in the `swiftly run` command. Also, this flag doesn't attempt to create a swift version file, or update it if it already exists.
95
+
96
+
## In use toolchains and default toolchains
97
+
98
+
When you list installed toolchains or use the `swiftly use` command to print the current in use toolchain there will be tags for both "in use" and "default." Sometimes the same toolchain will have both tags!
99
+
100
+
```
101
+
$ swiftly list
102
+
Installed release toolchains
103
+
----------------------------
104
+
Swift 6.0.3
105
+
Swift 6.0.2 (in use) (default)
106
+
107
+
Installed snapshot toolchains
108
+
-----------------------------
109
+
```
110
+
111
+
Whenever a toolchain is tagged as "in use" indicates the toolchain that will be used when running toolchain commands from your current working directory. The one that is selected is based either on what is in a `.swift-version` file or the global default if there is no such file there.
112
+
113
+
The default tag is used to show the global default toolchain, which is independent of any swift version file. The global default is there for cases where the file doesn't exist. It sets the toolchain that is in use in those cases.
if case let.swiftVersionFile(versionFile, _, _)= result {
111
-
if !assumeYes {
112
-
SwiftlyCore.print("The file `\(versionFile)` will be updated to set the new in-use toolchain for this project. Alternatively, you can set your default globally with the `--global-default` flag. Proceed with modifying this file?")
SwiftlyCore.print("A new file `\(newVersionFile)` will be created to set the new in-use toolchain for this project. Alternatively, you can set your default globally with the `--global-default` flag. Proceed with creating this file?")
0 commit comments