Include a framework in an Applescript application?

Hello,

I’ve written an Applescript application that (among other things) launches the new Shoebill emulator (which runs the old AU/X operating system originally written for ancient Macs).

The command-line version of the Shoebill emulator requires the SDL2.framework to be available, and the normal way to do this is to download and install it in OS X. Is there any way to include that framework in the application bundle itself?

My abilities don’t extend to creating an Applescript application in Xcode, just in the Applescript editor, though I suppose it may be time to learn this skill, finally.

And a related question: is there a test I can perform to see whether the SDL2 framework is installed? I could test for the folder in /Library/Frameworks, but it could also be other places, and it seems more reliable to test whether the system already has it.

Many thanks for any help.

You could try putting it in a folder called Frameworks inside the bundle’s Contents directory, but I doubt the emulator will find it there. I suspect the best you could achieve would be to offer to copy it to a system Frameworks folder if you can’t find it there already.

It’s possible. When the path to library starts with variable @executable_path or @loader_path, it’s quite easy and could be done like Shane suggested. Otherwise you need to instruct dlopen, by setting environment variables, that it need to search inside the application bundle. In practice this means the application is required to be launched by a script or launched by something like the terminal after you have set the right variables.

To get this information you could use otool which can list the required libraries of an executable. Once you have otools installed you could use something like this:

do shell script "otool -L /Applications/iTunes.app/Contents/MacOS/iTunes"

My suggestion would be using otool to look if the library/framework is installed and if not download it and install it in /Library/Frameworks.

note: otool ships with Xcode.

Thank you - this is all extremely useful. I’ve got my script working now, thanks to your help.