[pigeon] Support Swift 6 at FlutterStandardMessageCodec #147127
Labels
p: pigeon
related to pigeon messaging codegen tool
P2
Important issues not at the top of the work list
package
flutter/packages repository. See also p: labels.
team-ecosystem
Owned by Ecosystem team
triaged-ecosystem
Triaged by Ecosystem team
Use case
I set Strict Concurrency Checking to complete in Xcode 15's Build Settings.
With this setting, warnings will be displayed where errors occur in Swift 6.
Currently, when I try to generate an
class SampleApi
with pigeon, the following warning occurs.Proposal
There are 4 ways to fix this warning.
pattern 1
Add
Sendable
(in objc:NS_SWIFT_SENDABLE
) toFlutterStandardMessageCodec
.@interface FlutterStandardMessageCodec : NSObject <FlutterMessageCodec>
This can be adopted by looking at the internal implementation of FlutterStandardMessageCodec and if it can be adapted to Sendable.
pattern 2
Add
MainActor
or other global actor toFlutterStandardMessageCodec
.This is a more restrictive option than pattern 1.
It can be adopted if
FlutterStandardMessageCodec
can be adapted to some global actor.However, if adopted, this is the most desirable pattern as it can be handled properly by Swift Concurrency.
pattern 3
Add
@unchecked Sendable
to generated ApiCodec class.If
FlutterStandardMessageCodec
is difficult to modify but can be adapted toSendable
, can adopt this pattern.pattern 4
Remove
SampleApiCodec.shared
and modifySampleApiSetup.codec
.codec
is used only in thesetUp
function and is called only once, so there is no need to keep it in a static variable, and can initialize it each time.If this idea is correct, you can adopt this pattern.
The text was updated successfully, but these errors were encountered: