Your Site Title

Flutter 调用 C/C++

1. C/C++注意事项

  1. dart:ffi 只能绑定C语言的符号, 所以C++需要加上 extern “C” attribute((visibility(“default”))) attribute((used))

  2. C/C++源码建议写在ios/Classes/native_add.cpp目录, 因为CocoaPods不允许源码在
    .podspec上层目录, 而gradle允许

Reference

Binding to native code using dart:ffi Dart/Flutter ffi (Foreig Function Interface) native callbacks eg: sqlite3_exec