Re: Modifying dyld behavior for framework
Re: Modifying dyld behavior for framework
- Subject: Re: Modifying dyld behavior for framework
- From: Mike Ferris <email@hidden>
- Date: Mon, 9 Dec 2002 17:40:10 -0800
Hi,
I'm trying to link my app with a Framework and include this framework
in my
app. (I dont have access to the source of this framework)
If I start my app and the Framework is NOT in the /Library/Frameworks
folder, my app crashes miserably with a dyld error.
otool -L gives a static path for the Framework, although the
Framework is
copied in the app bundle.
Question 1: can I change the behavior of a framework, even if it has
not
been compiled with the @executable_path=../Frameworks?
I've tried to change DYLD_FRAMEWORK_PATH and launch with the terminal
with
no success.
If you are building the framework you can change this. If you are not,
you probably can't. Actually, you can change the install_name of a
framework after it has been built with install_name_tool, but you can
only safely do so if it was built with the -headerpad_max_install_names
option.
What you can do, though, as long as you don't want other things like
plug-ins to be able to link your embedded framework, is built your app
with -headerpad_max_install_names and use install_name_tool to modify
where the app has recorded the framework should be (changing it to the
"@executable_path" blah blah value.
In any case, setting DYLD_FRAMEWORK_PATH can be used to override all
this. I do not know why it did not work when you tried it... did you
use setenv or export (for csh-like or sh-like shells respectively)?
Question 2: how can I detect at runtime if the framework is in
/Library/Frameworks or (~/Library/Frameworks) and display a meaningful
message before dying?
You really can't in any simple way.
I answer to myself:
I load the framework at runtime using
NSBundle *myBundle=[NSBundle bundleWithPath:[NSString
stringWithFormat:@"%@/%@",[thisBundle
privateFrameworksPath],@"Yada.framework"]];
Now, how can I detect that the framework hasnt already been loaded,
since it
doesnt declare any class? If it did, I could have used
NSClassFromString?
If you have no classes, use the dyld API to look up a function
pointer... see <mach-o/dyld.h> for the APIs...
Mike Ferris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.