Add FFI and JNI support to Swift and Kotlin#11352
Add FFI and JNI support to Swift and Kotlin#11352tarrinneal wants to merge 102 commits intoflutter:mainfrom
Conversation
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Some very early review notes; since it's going to be a long review I thought I should post things incrementally. So far I've mostly just looked at the smaller bits, not the full generators yet (and not the tests).
Please also add a real PR description, with issue references and a high level overview of the PR (what it does, what generators it covers, what's in and out of scope here, etc.)
| return true | ||
| } | ||
|
|
||
| return innerValue is NSNull |
There was a problem hiding this comment.
What's the reason for making this method so verbose instead of just ||ing the condition onto the existing statement?
There was a problem hiding this comment.
The check if case Optional<Any>.some(Optional<Any>.none) = value uses pattern matching. This is a control flow statement, not a boolean expression so it can't be used with logical ||
| } | ||
|
|
||
| /// Wraps provided [toWrap] with [start] and [end] if [wrap] is true. | ||
| String wrapConditionally(String toWrap, String start, String end, bool wrap) { |
There was a problem hiding this comment.
I assume this is so that toWrap can be an expression, without having to hoist that expression into a local variable to be able to use the statement below?
There was a problem hiding this comment.
yeah, It can be worse than that too. This can resolve some manual indentation that has been happening.
This PR introduces optional Native Interop to Pigeon, enabling direct communication between Dart and native code without the overhead of traditional MethodChannel serialization. It leverages FFI (Foreign Function Interface) for Swift (iOS/macOS) and JNI (Java Native Interface) for Kotlin (Android).
This represents a significant architectural shift, moving from message-based passing to direct memory sharing and function calls. It also updates the concurrency model for asynchronous methods, moving from completion handlers/callbacks to modern language features: async/await in Swift and Coroutines in Kotlin.
Generators Covered
Swift Generator: Updated to support FFI bindings and async/await for asynchronous methods.
Kotlin Generator: Updated to support JNI bindings and Kotlin Coroutines for asynchronous methods.
Dart Generator: Updated to handle the generated interop bindings on the Dart side.
What's In Scope
Tests: Added ni_tests.dart and associated generated files and integration tests to verify the feature.
What's Out of Scope
work toward flutter/flutter#182230
design doc flutter/flutter#181430