Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the cleanest way to set the environmental variable DYLD_FRAMEWORK_PATH for a release build?

I have custom frameworks in my app bundle for WebKit, WebCore, and JavaScriptCore. I would like all other frameworks that depend on the system versions of WebKit, WebCore, or JavaScriptCore to use my custom versions also. For instance my custom version of Webkit loads private system frameworks that in turn depend on the system version of WebKit. This means both my WebKit and the system WebKit get loaded, and usually a crash happens shortly after.

The way I understand this should be done, is to set the DYLD_FRAMEWORK_PATH environmental variable before your app bundle begins execution (Search order for loading frameworks can be found here: http://code.google.com/p/macdependency/wiki/SearchPaths). You can set environmental variables in code with setenv, but it won't take effect for the currently running process. I would have to re-launch the process again for it to take effect. I would like to avoid this too.

So my question is what is the best way to set the DYLD_FRAMEWORK_PATH before the execution of the my app bundle? This has to work in a release app bundle too. Is there a way to run a script whenever someone clicks on my app bundle before the executable starts running. Or is there any other suggestions out there?

Thanks in advance.

like image 266
Michael Wildermuth Avatar asked Feb 07 '12 19:02

Michael Wildermuth


2 Answers

Jeff Wolski has the right idea by referring directly to Apple's documentation on the subject. This thread also provides excellent advice on how to get that going in Xcode, including corner cases associated with alternative methods of specification (for example, by using ~/.bash_profile directly for your user).

My reason for chiming in is you also asked for a script that might be able to assist you (and a bounty provider appears to have the same issue). It turns out Webkit references such a script in its documentation, which you might want to pick apart from the applicable Webkit source code. This should give you additional guidance on how, at least according to the developers, you should do this properly.

Best of luck with your project(s).

like image 122
MrGomez Avatar answered Oct 04 '22 06:10

MrGomez


I would recommend environment.plist or the LSEnvironment key in the info.plist. Check out the link below.

https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html

like image 41
Jeff Wolski Avatar answered Oct 04 '22 05:10

Jeff Wolski