Best practice for copying dylib on build

Our plugin uses a dylib that needs to copied on build to sit next to the executable, and code-signed at the same time.

It seems that adding a copy phase in XCode is not viable because this will be overwritten by the Projucer.

Is there a best practice for achieving this in JUCE? Thanks!

My workaround was to add the dylib as a binary resource, then save it as a temporary file at runtime and dlopen it as needed.

I am using the field “Custom Xcode Resource folders” in the projucer exporter. These folders will be copied into the bundle under Contents/Resources/folder_name.

Then you have to add that path to the rpath using the install_name_tool. And the libraries need that rpath set properly, which I managed sometimes using said tool, but not for all cases.

For the second step I would welcome recommendations.