Author Topic: Using bass_fx on iOS with Delphi  (Read 223 times)

DelphiWorlds

  • Posts: 2
Using bass_fx on iOS with Delphi
« on: 10 Apr '24 - 01:00 »
I've managed to make bass_fx work on Android, Windows and macOS, but I am having trouble making it work on iOS. Here's what I have tried:

Changed the defines for bass_fxdll thus:

Code: [Select]

        {$IF Defined(MSWINDOWS)}
bass_fxdll = 'bass_fx.dll';
{$ELSEIF Defined(OSX)}
bass_fxdll = 'libbass_fx.dylib';
{$ELSEIF Defined(IOS)}
bass_fxdll = 'bass_fx';
{$ELSE}
bass_fxdll = 'libbass_fx.so';
{$ENDIF}

..and included the path to the bass_fx.framework under the ios-arm64_armv7_armv7s folder (i.e. binaries for real devices)

All compiles OK, but the app crashes on startup and I'm having trouble finding any crash logs (which I'll continue to look for)

Any ideas as to what I need to do?

Ian @ un4seen

  • Administrator
  • Posts: 25847
Re: Using bass_fx on iOS with Delphi
« Reply #1 on: 10 Apr '24 - 13:19 »
I'm not a Delphi user myself, so I'm not familiar with the specifics of that, but if the BASS library is working fine, the BASS.PAS file has the following:

Code: [Select]
{$IFDEF MSWINDOWS}
  bassdll = 'bass.dll';
{$ENDIF}
{$IFDEF LINUX}
  bassdll = 'libbass.so';
{$ENDIF}
{$IFDEF ANDROID}
  bassdll = 'libbass.so';
{$ENDIF}
{$IFDEF MACOS}
  {$IFDEF IOS}
    bassdll = 'bass.framework/bass';
  {$ELSE}
    bassdll = 'libbass.dylib';
  {$ENDIF}
{$ENDIF}

So you could try the same thing in BASS_FX.PAS:

Code: [Select]
...
  {$IFDEF IOS}
    bass_fxdll = 'bass_fx.framework/bass_fx';
...

If it still isn't working, are you also using any other add-ons and are they working?

DelphiWorlds

  • Posts: 2
Re: Using bass_fx on iOS with Delphi
« Reply #2 on: 10 Apr '24 - 22:47 »
In my BASS.pas, I had:

Code: [Select]
{$IFDEF MSWINDOWS}
  bassdll = 'bass.dll';
{$ENDIF}
{$IFDEF LINUX}
  bassdll = 'libbass.so';
{$ENDIF}
{$IFDEF ANDROID}
  bassdll = 'libbass.so';
{$ENDIF}
{$IFDEF MACOS}
  {$IFDEF IOS}
    bassdll = 'libbass.a';
  {$ELSE}
    bassdll = 'libbass.dylib';
  {$ENDIF}
{$ENDIF}

Because I was using the static library for iOS. bass_fx has only a dynamic library (framework), so I should have realised it depends on the dynamic library for bass (I confirmed this using the otool command). Now I am using the defines in bass.pas that you posted, and modified bass_fx similarly:

Code: [Select]
{$IF Defined(MSWINDOWS)}
bass_fxdll = 'bass_fx.dll';
{$ELSEIF Defined(OSX)}
bass_fxdll = 'libbass_fx.dylib';
{$ELSEIF Defined(IOS)}
bass_fxdll = 'bass_fx.framework/bass_fx';
{$ELSE}
bass_fxdll = 'libbass_fx.so';
{$ENDIF}

The next problem was that usually, frameworks are deployed with a remote path of (for example with bass_fx) Frameworks\bass_fx.framework. Having finally found where the crash reports are, I discovered:

Code: [Select]
"type": "EXC_CRASH",
"signal": "SIGABRT"
},
"termination": {
"code": 1,
"flags": 518,
"namespace": "DYLD",
"indicator": "Library missing",
"details": [
"(terminated at launch; ignore backtrace)"
],
"reasons": [
"Library not loaded: @rpath/bass_fx.framework/bass_fx",
"Referenced from: <6DA6D33F-949E-3D2D-9FC5-7626BF6D85E3> /Volumes/VOLUME/*/CDGFMX.app/CDGFMX",
"Reason: tried: '/private/var/containers/Bundle/Application/B4AAC5E1-E9E4-4FE8-8C1E-D532674CC973/CDGFMX.app/bass_fx.framework/bass_fx' (no such file), '/private/var/containers/Bundle/Application/B4AAC5E1-E9E4-4FE8-8C1E-D532674CC973/CDGFMX.app/bass_fx.framework/bass_fx' (no such file)"

...so it was trying to load without the Frameworks part of the path. I updated the remote path values in the deployment, and now it works! Thanks for your reply, because it sent me down the right track.



Ian @ un4seen

  • Administrator
  • Posts: 25847
Re: Using bass_fx on iOS with Delphi
« Reply #3 on: 11 Apr '24 - 15:05 »
Good to see that you've got it working. I've put an updated BASS_FX.PAS file with support for iOS (and macOS) in the BASS_FX package now, so that others won't need to update it themselves.