-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Added migration guide for 1.15 #3390
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
+50
−0
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
49 changes: 49 additions & 0 deletions
49
...ableArchitecture/Documentation.docc/Articles/MigrationGuides/MigratingTo1.15.md
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,49 @@ | ||
# Migrating to 1.15 | ||
|
||
The library has been completely updated for Swift 6 language mode, and now compiles in strict | ||
concurrency with no warnings or errors. | ||
|
||
## Overview | ||
|
||
The library is now 100% Swift 6 compatible, and has been done in a way that is full backwards | ||
compatible. If your project does not have strict concurrency warnings turned on, then updating | ||
the Composable Architecture to 1.15.0 should not cause any compilation errors. However, if you have | ||
strict concurrency turned on, then you may come across a few situations you need to update. | ||
|
||
### Enum cases as function references | ||
|
||
It is common to use the case of enum as a function, such as mapping on an ``Effect`` to bundle | ||
its output into an action: | ||
|
||
```swift | ||
return client.fetch() | ||
.map(Action.response) | ||
``` | ||
|
||
In strict concurrency mode this may fail with a message like this: | ||
|
||
> 🛑 Converting non-sendable function value to '@Sendable (Value) -> Action' may introduce data races | ||
|
||
There are two ways to fix this. You can either open the closure explicitly instead of using | ||
`Action.response` as a function: | ||
|
||
```swift | ||
return client.fetch() | ||
.map { .response($0) } | ||
``` | ||
|
||
There is also an upcoming Swift feature that will fix this. You can enable it in an SPM package | ||
by adding a `enableUpcomingFeature` to its Swift settings: | ||
|
||
```swift | ||
swiftSettings: [ | ||
.enableUpcomingFeature("InferSendableFromCaptures"), | ||
]), | ||
``` | ||
|
||
And you can [enable this feature in Xcode](https://www.swift.org/blog/using-upcoming-feature-flags/) | ||
by navigating to your project's build settings in Xcode, and adding a new "Other Swift Flags" flag: | ||
|
||
``` | ||
-enable-upcoming-feature InferSendableFromCaptures | ||
``` |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly I found this wasn't effective in my codebase. We're on Xcode 15.4. Even with
-enable-experimental-feature InferSendableFromCaptures -enable-upcoming-feature InferSendableFromCaptures
in theSwiftCompile
output in the build log, I still get that error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @JimRoepcke, I'm not able to reproduce this, but if you can provide a minimal project that demonstrates the problem we will look into more. For now I am going to merge this as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @JimRoepcke
If you using local SwiftPackage, you should configure upcoming feature on Package.swift for SwiftPackage source code.
Configured
OTHER_SWIFT_FLAGS
in xcodeproj is not affect to SwiftPackage in my case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake was I was using Xcode 15.4 thinking this feature flag worked in that toolchain. It requires Xcode 16!