Repository navigation
Closed
flutter/packages
#13153Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
Found while investigating #193195.
Summary
Pigeon accepts Swift FFI mode for pigeon files that contain event channels or ProxyApis, but the Swift it generates doesn't compile. Users get a wall of Swift errors instead of a clear message at generation time.
Steps to reproduce
- Write a pigeon file with a
@HostApi()and an@EventChannelApi(), or use pigeon's ownpigeons/event_channel_tests.dartorpigeons/proxy_api_tests.dart. - Generate Swift with FFI enabled (
--swift_use_ffi, orSwiftOptions(useFfi: true)). - Type-check the generated file against the SDK, the way swiftgen compiles it:
xcrun swiftc -typecheck -sdk "$(xcrun --show-sdk-path --sdk macosx)" Generated.swift
Expected results
Either pigeon rejects the input with a clear error, or the generated Swift compiles.
Actual results
Pigeon writes the file without complaint, and it fails to type-check:
| Input | Result |
|---|---|
| Host API only | Compiles |
pigeons/native_interop_tests.dart |
Compiles |
| Host API + 1 event channel | 56 errors; 34 are missing Flutter types (FlutterEventSink, FlutterStandardReader/Writer, FlutterError) |
pigeons/event_channel_tests.dart |
208 errors |
pigeons/proxy_api_tests.dart |
1,118 errors |
Cause
- In FFI mode the Swift generator skips
import Flutter/import FlutterMacOS(swift_generator.dart L318). - It uses the FFI codec only when the file has no event channels and no ProxyApis. Otherwise it falls back to the channel codec, which is built on
FlutterStandardReader/Writer(L530). The event channel and ProxyApi code also uses Flutter types directly. - Swift FFI validation checks only
@TaskQueueand package dependencies (pigeon_lib_internal.dart L603–620), so nothing stops the combination. - Adding the Flutter import wouldn't fix it. swiftgen compiles the file with
swiftcagainst the bare SDK, without a Flutter framework search path.
The Kotlin JNI side doesn't have this compile problem: in JNI mode the Kotlin generator imports the Flutter embedding for files with event channels or ProxyApis.
Proposed fix
- Now: in Swift FFI validation, reject files that contain event channels or ProxyApis, with a message such as: "Event channels and ProxyApis are not supported with Swift FFI yet. Move them to a separate pigeon file that doesn't use
swift_use_ffi." - Later, as separate designs:
- event channels over native interop, for example as FlutterApi-style calls from native to Dart;
- ProxyApis over FFI.
Environment
pigeon 29.0.6, swiftgen 0.2.0, ffigen 22.0.0, Xcode 16.4 (Swift 6.1.2), macOS SDK.
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Activity
[pigeon] Reject unsupported native interop features and fix generated…
github-actions commentedon Oct 23, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.