0

I'm trying to integrate the BASS audio library from un4seen Developments with Flutter, Google's cross-platform app development environment. I've started a Flutter plugin that can be found here: https://github.com/JimTompkins/flutter_bass. It uses Flutter's FFI (foreign function interface) mechanism and a package called ffigen to convert the bass.h file to generated_bindings.dart.

Here is a snippet from generated_bindings.dart:

  int BASS_Init(
    int device,
    int freq,
    int flags,
    ffi.Pointer<ffi.Void> win,
    ffi.Pointer<ffi.Void> dsguid,
  ) {
    return _BASS_Init(
      device,
      freq,
      flags,
      win,
      dsguid,
    );
  }

  late final _BASS_InitPtr = _lookup<
      ffi.NativeFunction<
          BOOL Function(ffi.Int32, DWORD, DWORD, ffi.Pointer<ffi.Void>,
              ffi.Pointer<ffi.Void>)>>('_BASS_Init');
  late final _BASS_Init = _BASS_InitPtr.asFunction<
      int Function(
          int, int, int, ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>)>();

It builds (Flutter 3.3, XCode 13) but throws a run-time error when I try to call the BASS_init function: Failed to lookup symbol '_BASS_Init': dlsym(0x100f61e18, _BASS_Init): symbol not found

I can see the symbol in the libbass.a file using nm -gU libbass.a

Any comments/suggestions welcomed!

Update 2022-09-20: I added the following frameworks to the Xcode build: AVFoundation, AudioToolbox, SystemConfiguration, CFNetwork, Accelerate In Xcode by going to Build Phase-->Link Binary with Libraries-->Add This did not make any difference i.e. still getting symbol error

I checked that “Enable bitcode” is set to “No” in Xcode under Build Settings-->Build Options.

The search continues...

Updated 2022-09-29: I got a hint from this Github issue post: use a force_load option to Xcode in the podspec file:

s.pod_target_xcconfig = {'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', "OTHER_LDFLAGS" => '-force_load ($SRCROOT)/../../../ios/bass24-ios/bass.xcframework/ios-arm64_armv7_armv7s/libbass.a' } s.vendored_libraries = '($SRCROOT)/../../../ios/bass24-ios/bass.xcframework/ios-arm64_armv7_armv7s/libbass.a'

I tried this but now I'm getting a file not found error.

Could not build the precompiled application for the device.

Error (Xcode): File not found:

(/Users/jimtompkins/git/flutter_bass/example/ios/Pods)/../../../ios/bass24-ios/bass.xcframework/ios-arm64_armv7_armv7s/libbass.a

I checked and the file is there:

% ls -als /Users/jimtompkins/git/flutter_bass/example/ios/Pods/../../../ios/bass24-ios/bass.xcframework/ios-arm64_armv7_armv7s/libbass.a                                     


1536 -rw-r--r--@ 1 jimtompkins  staff  785096  8 Sep  2021 /Users/jimtompkins/git/flutter_bass/example/ios/Pods/../../../ios/bass24-ios/bass.xcframework/ios-arm64_armv7_armv7s/libbass.a

Any hints greatly appreciated!

Update: 2022-09-30: fixed by removing ( ) around the $SRCROOT.
I also found that I needed to add the necessary frameworks to the OTHER_LDFLAGS command in the podspec file. See the Github repo.

0 Answers0