native icon indicating copy to clipboard operation
native copied to clipboard

Support implementing ObjC protocols from Dart

Open liamappelbe opened this issue 1 year ago • 5 comments
trafficstars

This should be possible with a single static piece of native code that can live in package:objective_c, so we won't have to generate different native code for each protocol.

liamappelbe avatar Mar 22 '24 00:03 liamappelbe

The fix for https://github.com/dart-lang/native/issues/835 is going to involve ffigen generating ObjC code for each block that the user needs. So there's not really any reason to try to avoid having ffigen generate native code anymore. It will be simpler and more efficient to just generate ObjC and Dart bindings for each interface that we want to implement from Dart, rather than having a generic thing like NSProxy that lives in package:objective_c.

liamappelbe avatar May 03 '24 03:05 liamappelbe

The fix for #835 is going to involve ffigen generating ObjC code for each block that the user needs.

How would we solve the bundling of that ObjC code? Am I correct in assuming that if it's a Flutter plugin I presume we write cocoapods code to include it, and if we use native assets, we'd need to have a ObjectiveCCodeAsset as output from hook/build.dart?

dcharkes avatar May 03 '24 08:05 dcharkes

Or can the Objective C just be compiled to a dylib and we can output it as a NativeCodeAsset @liamappelbe ?

dcharkes avatar May 03 '24 08:05 dcharkes

I'm not sure what the difference is between ObjectiveCCodeAsset and NativeCodeAsset, but the code can be bundled as an ordinary dylib.

liamappelbe avatar May 05 '24 21:05 liamappelbe

I'm not sure what the difference is between ObjectiveCCodeAsset and NativeCodeAsset, but the code can be bundled as an ordinary dylib.

👍 Then we don't need an ObjectiveCCodeAsset.

dcharkes avatar May 06 '24 05:05 dcharkes