Using frameworks in a command line tool

Unfortunately, there is no way to bundle a framework with a command-line Utility in OS X and I suspect that the framework you’re linking to is expecting to be bundled in the app bundle’s Frameworks/ directory. If you have access to the framework source code, you can compile a static library and statically link it to your application (or include the source in your application target directly). If you don’t have the source code or you don’t want to statically link the library for some reason, there are two remaining options:

  1. If you have access to the system-wide /Library/Frameworks folder, you can install the 3rd party framework there. This require that the framework’s Installation Path (the INSTALL_PATH build setting) be set to /Library/Frameworks at build time or that you use the install_name_tool to change the frameworks install path to /Library/Frameworks (if you don’t have the framework’s source code).

  2. Build an application bundle (as if you were building a GUI app) with your command-line utility as the app bundle’s executable (i.e. in AppBundle.app/Contents/MacOS/). You can then copy the 3rd party framework to the app bundle’s frameworks directory. You can then put the app bundle anywhere you want and create a symbolic link to the command line utility.

Option 1 is definitely the more accepted approach, but I’ve used option 2 when there was a valid reason.

You can find more information on building, linking, and installing frameworks in Apple’s Frameworks Programming Guide.

Leave a Comment