The question is better answered by informing yourself of how dynamic libraries are found by applications on the platform, in this case macOS.

As far as I know, it basically comes down to:

1. Applications look in ~/lib, /usr/local/lib, and /usr/lib by default.
2. As you've found with Purr Data, an app bundle will also look in Contents/libs.
3. Applications will also look in other places listed in environment variables.
4. You can fiddle with the search path used per library when it's linked using install_name_tool.

See the docs:

https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/UsingDynamicLibraries.html#//apple_ref/doc/uid/TP40002182-SW10

or

https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/RunpathDependentLibraries.html

or lots of posts on SO like

https://stackoverflow.com/questions/38685581/how-to-set-dylib-search-path-osx

For distributing a plugin like an external via deken, options 1-3 are probably out to some degree. Option 4 however is not easy either as the path set by install_name_tool has to be relatively specific, in my experience. Getting it to work with the dylib sitting "wherever" on someone else machine is not so easy, unfortunately.

Gem makes this work, so I would check how they do it for macOS.

The other, simpler alternative is to statically link fluidsynth into the external. You then have a larger pd_darwin but no dependencies or dylib search paths. If homebrew installs a statically-built  libfluidsynth.a to /usr/local/lib, you can use that.

On Dec 12, 2020, at 2:29 AM, pd-list-request@lists.iem.at wrote:

Message: 3
Date: Fri, 11 Dec 2020 22:28:33 -0300
From: Alexandre Torres Porres <porres@gmail.com>
To: Esteban Viveros <emviveros@gmail.com>
Cc: Jonathan Wilkes <jancsika@yahoo.com>, Pd-List
<pd-list@lists.iem.at>
Subject: Re: [PD] fluid~
Message-ID:
<CAEAsFmh701xsCJ8g95+Tt1=6FE-68kHeHsjdw3shLffQJLT75Q@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

my searching app failed me, I found libfluidsynth.2.dylib in Contents/lib
in Purr Data's app!

So yeah, the question still remains, how can we make Pd find this. It
failed to do so if it's just in the same folder. And also if we can build
the external binary that already has libfluidsynth.2.dylib embedded in it.

cheers

--------
Dan Wilcox
@danomatika
danomatika.com
robotcowboy.com