Embedding Frameworks in Applications
27 May 2004, 10:46 PM Filed in: …on Software
If your Mac OS X application uses a framework, you can embed it in your application even after you’ve built and linked the application against a framework which you’ve installed privately to /Library/Frameworks
.
The secret is to use the obscure install_name_tool
command. You’ll need to do two things:
- Change the identification name of the framework itself from
Foo.framework/...
to@executable_path/../Frameworks/Foo.framework/...
- Change the application’s main executable dependent shared library list, from
Foo.framework/...
to@executable_path/../Frameworks/Foo.framework/...
Here’s how to do it:
- Copy your existing framework first and work on that: the
install_name_tool
command directly modifies the framework, so you’ll probably want be operating on a copy of it. - Run
install_name_tool -id '@executable_path/../Frameworks/Foo.framework/...' Foo.framework/Foo
- Run
install_name_tool -change 'Foo.framework/...' '@executable_path/../Frameworks/Foo.framework/...' MyApplication.app/Contents/MacOS/MyApplication
To find out what to put in the ...
bit of the commands above, run the otool -L
command on the executable or shared library to see the full pathname. It should look something like Versions/A/Foo
.
It’s a bit of a pain in the arse, but at least it works. Until I figured this out, it was really a bit of a pain to embed frameworks into applications properly!
Comments