Re: Locating a Framework in a Non-Standard Directory
Re: Locating a Framework in a Non-Standard Directory
- Subject: Re: Locating a Framework in a Non-Standard Directory
- From: "Gustavo Vera" <email@hidden>
- Date: Thu, 15 Mar 2007 10:53:05 -0300
First of all, Thank you very much! Your answer help me to solve the problem.
Right down are the steps I followed. Again thanks!
On 3/14/07, Sherm Pendley <email@hidden> wrote:
The frameworks path you set up on Xcode is only used at compile time.
At compile time, the framework's install name is copied into the app
binary. At run time, the loader reads the copied install name from
the app binary, and uses that to locate the library binary.
Use install_name_tool to change the install name of the framework.
You'll need to re-link your app after you do that, so the framework's
new install name is copied into your app binary. For many frameworks
the new install name cannot be longer than the old one. (Defining a
larger buffer size for the install name is a framework build option,
but it's not done by default. By default, the buffer is exactly the
number of bytes needed for the install name as defined when the
library was built.)
I couldn't change the install name of the framework with this tool, but
even if I could, if in the change process I couldn't provide a longer path,
that shouldn't work either.
Install_name_tool can also change the copy of an install name in an
application binary, but that's less useful - since that's copied from
the framework by the linker, you'd have to add a script build step to
your build to re-run it every time you build your app.
This was the correct approach in my case, actually. This is the script I'm
using:
echo "******* Fixing LogoSync framework location inside app bundle ....
*******"
install_name_tool -change ./LogoSync.framework/Versions/A/LogoSync
@executable_path/../Frameworks/LogoSync.framework/Versions/A/LogoSync
$BUILT_PRODUCTS_DIR/TetraChrome.app/Contents/MacOS/TetraChrome
echo "********* LogoSync framework location inside app bundle fixed.
**********"
The previous script, with an extra copy files build step, solved my problem.
As you can see, I abandoned the idea of a fixed custom location for this
framework at /Library/Frameworks/TetraChrome and now I'm just embedding the
framework inside the app bundle.
Another option would be to change the beginning of the framework's
install name to @executable_path/../Frameworks/etc. The first
component expands to the application binary itself, not the .app
directory, so at run time the loader will look for YourApp.app/
Contents/Frameworks/etc.
When I read this the first time, I understand that you was referring to a
change in the referenced framework, and this implies a longer install name,
so I discarded. But if you was referring to the app bundle, then this is
actually what I did.
With this option, it's common to add a "Copy
Files" build step to your target, set it to copy to "Frameworks/",
and add the framework(s) you want to copy to that build step by
dragging them from Xcode's "Frameworks/" file group.
Also done.
If your framework is part of an application suite, you can share it
among all the suite's apps. If there is a "master" app in the suite,
you could bundle the framework with that, and set its install name to
"@executable_path/../../../Master.app/Contents/Frameworks/". Or you
could keep your suite's frameworks in a folder of their own, and use
install names beginning with "@executable_path/../../../Frameworks/".
> Is there a chance that, with some frameworks, you can only use it
> correctly
> if they are installed on the standard locations??.
It's possible, but not likely to be the case in my opinion.
Frameworks are designed to be easily relocatable by nature, although
if the authors wanted to "anchor" it to a specific location they
certainly could.
sherm--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden