Skip to content

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
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ APIs, and these guides contain tips to do so.

## Topics

- <doc:MigratingTo1.15>
- <doc:MigratingTo1.14>
- <doc:MigratingTo1.13>
- <doc:MigratingTo1.12>
Expand Down
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"),
]),
Comment on lines +39 to +41

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 the SwiftCompile output in the build log, I still get that error.

Copy link
Member Author

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.

Copy link

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.

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!

```

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
```
Loading