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
Copy file name to clipboardExpand all lines: proposals/NNNN-adoption-tooling-for-swift-features.md
+57-6Lines changed: 57 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,6 +160,63 @@ belong to a diagnostic group named after the feature.
160
160
The names of diagnostic groups can be displayed alongside diagnostic messages
161
161
using `-print-diagnostic-groups` and used to associate messages with features.
162
162
163
+
### `swift migrate` command
164
+
165
+
To enable seemless migration experience for Swift packages, I'd like to propose a new Swift Package Manager command - `swift migrate` to complement the Swift compiler-side changes.
166
+
167
+
The command would accept one or more features that have migration mode enabled and optionally a set of targets to migrate, if no targets are specified the whole package is going to be migrated to use new features.
168
+
169
+
#### Interface
170
+
171
+
```
172
+
USAGE: swift migrate [<options>] --to-feature <to-feature> ...
173
+
174
+
OPTIONS:
175
+
--targets <targets> The targets to migrate to specified set of features or a new language mode.
176
+
--to-feature <to-feature>
177
+
The Swift language upcoming/experimental feature to migrate to.
178
+
-h, --help Show help information.
179
+
```
180
+
181
+
#### Use case
182
+
183
+
```
184
+
swift migrate --targets MyTarget,MyTest --to-feature ExistentialAny
185
+
```
186
+
187
+
This command would attempt to build `MyTarget` and `MyTest` targets with `ExistentialAny:migrate` feature flag, apply any fix-its associated with
188
+
the feature produced by the compiler, and update the `Package.swift` to
189
+
enable the feature(s) if both of the previous actions are successful:
190
+
191
+
```
192
+
.target(
193
+
name: "MyTarget",
194
+
...
195
+
swiftSettings: [
196
+
// ... existing settings,
197
+
.enableUpcomingFeature("ExistentialAny")
198
+
]
199
+
)
200
+
...
201
+
.testTarget(
202
+
name: "MyTest",
203
+
...
204
+
swiftSettings: [
205
+
// ... existing settings,
206
+
.enableUpcomingFeature("ExistentialAny")
207
+
]
208
+
)
209
+
```
210
+
211
+
In the "whole package" mode, every target is going to be updated to include
212
+
new feature flag(s). This is supported by the same functionality as `swift package add-setting` command.
213
+
214
+
If it's, for some reason, impossible to add the setting the diagnostic message would suggest what to add and where i.e. `...; please add '.enableUpcomingFeature("ExistentialAny")' to `MyTarget` target manually`.
215
+
216
+
#### Impact on Interface
217
+
218
+
This proposal introduces a new command but does that does not interfere with existing commands. It follows the same pattern as `swift build` and `swift test` in a consistent manner.
219
+
163
220
## Source compatibility
164
221
165
222
This proposal does not affect language rules.
@@ -217,12 +274,6 @@ is essential for future tools built around migration mode:
217
274
Furthermore, tools can take advantage of this information by favoring and
218
275
auto-applying source-compatible fix-its.
219
276
220
-
### `swift migrate`
221
-
222
-
The Swift package manager could implement a `migrate` subcommand for interactive
223
-
review and application of migration mode output for a given set of features,
224
-
with a command-line interface similar to `git add --patch`.
0 commit comments