0

We are experimenting with Dart ffi (foreign function interface) and are looking to directly call into the IOS AVFoundation dylib from dart.

To use ffi we need to dynamically load the AVFoundation dylib.

These leads to several questions.

  1. how do we find the path of the AVFoundation dylib?
  2. how do we get/find a list of entry points into the dylib?
  3. do we load the dylib directly or do we need to load it via a framework?
  4. we are likely to need to load other dylibs (for core features) so ideally we need a generic method of identifying the path to the dylib and its set of entry points.

Will we have any trouble shipping an app that uses dynamically loaded dylibs? I come across something (which I've now lost) that seems to be suggesting that the app store may not allow an app to be uploaded that uses dynamic loading.

We are considering an alternate path which is to create a small objective-c library that effectively proxies through the calls from av foundation, however we are trying to avoid any objective-c/swift code.

Brett Sutton
  • 3,900
  • 2
  • 28
  • 53
  • What do you mean by "entry points"? Exported symbols? – Siguza Dec 02 '20 at 11:36
  • The method I've used is to create the normal C export file that exposes your API you will `lookup` in Dart FFI. Those stubs are used to create C++ classes with the methods you need, with those classes implemented in Objective C++ files (.mm) where they have access to AVFoundation. That's actually not too messy. (What *was* messy was dealing with callbacks from ObjC into C++ - but it's possible.) – Richard Heap Dec 02 '20 at 14:45
  • @Siguza yes the exported symbols. We are trying to call function 'x' so we need to know which dylib function 'x' is located in (function 'x' being the entry point we are looking for). – Brett Sutton Dec 03 '20 at 22:21
  • @RichardHeap that is our fallback strategy, but we were hoping to eliminate all native code to make long term support of the library easier by using only a single language (dart). Do you have any sample code you could share? – Brett Sutton Dec 03 '20 at 22:23
  • @BrettSutton In that case, I suggest searching through the folder `/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk`. The `.tbd` files in there contain library paths as well as a list of exported symbols. – Siguza Dec 03 '20 at 23:14

0 Answers0