dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
106 stars 36 forks source link

FFI will not run in release mode unless the Testability flag is set (IOS) #924

Open EPADDO opened 11 months ago

EPADDO commented 11 months ago

Hello, I have some C which I have used the FFI interface to reference C functions. It works perfectly in debug mode on IOS14 device and it also works perfectly on the release mode but only if I enable the testability flag. No matter what else is tried inclusive of changing the strip style to non global, the method cannot be found for the C routine. In addition, it is not C++ code so I cant specify the attribute flag. It seems that the symbols are stripped out that references the method. Is there any other work around for this? Tried calling: call(Pointer: address=0x122f0e160, 32, Pointer: address=0x282a955c0)

0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38)

dart-lang/ffi#1 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85) dart-lang/ffi#2 speex_enc_dec.encodeAudio (package:rapid_app/speex_enc_dec.dart:166) dart-lang/ffi#3 onStart. (package:rapid_app/main.dart:430) dart-lang/ffi#4 _RootZone.runUnaryGuarded (dart:async/zone.dart:1593)

Regards David.

dcharkes commented 11 months ago

Did you use flutter create --template=plugin_ffi --platform=ios?

Trying to use FFI from scratch often has issues with bundling (see the existing iOS issues on the Flutter repository). That is why we have created that template. Please use that template.

EPADDO commented 11 months ago

Thank-you. I shall try that method and revert back.

EPADDO commented 10 months ago

Hello, that has fixed the issue. I do have one question though, these flags were not honoured and I needed to set some of the defines manually in the c code s.compiler_flags the -D flags are not used when the plugin compiles. = [ '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w', '-DFIXED_POINT', '-DUSE_KISS_FFT', '-UHAVE_CONFIG_H',

]