xcode 为发布版本设置环境变量 DYLD_FRAMEWORK_PATH 的最干净的方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9182325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the cleanest way to set the environmental variable DYLD_FRAMEWORK_PATH for a release build?
提问by Michael Wildermuth
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.
我的应用程序包中有用于 WebKit、WebCore 和 JavaScriptCore 的自定义框架。我希望所有其他依赖于 WebKit、WebCore 或 JavaScriptCore 系统版本的框架也使用我的自定义版本。例如,我的 Webkit 自定义版本加载了私有系统框架,而这些框架又取决于 WebKit 的系统版本。这意味着我的 WebKit 和系统 WebKit 都被加载,通常不久之后就会发生崩溃。
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.
我理解应该这样做的方式是在您的应用程序包开始执行之前设置 DYLD_FRAMEWORK_PATH 环境变量(加载框架的搜索顺序可以在这里找到:http: //code.google.com/p/macdependency/wiki/SearchPaths)。可以使用setenv在代码中设置环境变量,但是对当前运行的进程不会生效。我必须再次重新启动该过程才能生效。我也想避免这种情况。
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?
所以我的问题是在执行我的应用程序包之前设置 DYLD_FRAMEWORK_PATH 的最佳方法是什么?这也必须在发布应用程序包中工作。每当有人在可执行文件开始运行之前单击我的应用程序包时,有没有办法运行脚本。或者还有其他建议吗?
Thanks in advance.
提前致谢。
回答by MrGomez
Jeff Wolski has the right ideaby referring directly to Apple's documentation on the subject. This threadalso 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).
杰夫·沃尔斯基 (Jeff Wolski)直接参考了 Apple 关于该主题的文档,他的想法是正确的。该线程还提供了关于如何在 Xcode 中实现这一点的极好建议,包括与替代规范方法相关的极端情况(例如,~/.bash_profile
直接为您的用户使用)。
My reason for chiming in is you alsoasked 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.
我加入的原因是您还要求提供一个可能能够帮助您的脚本(赏金提供者似乎也有同样的问题)。事实证明,Webkit在其文档中引用了这样一个脚本,您可能希望将其与适用的 Webkit 源代码分开。这应该为您提供额外的指导,至少根据开发人员的说法,您应该如何正确地执行此操作。
Best of luck with your project(s).
祝你的项目好运。
回答by Jeff Wolski
I would recommend environment.plist
or the LSEnvironment
key in the info.plist
. Check out the link below.
我建议environment.plist
还是LSEnvironment
在关键的info.plist
。查看下面的链接。
回答by Litherum
WebKit currently has a script to do this for you, called run-webkit-app. See http://trac.webkit.org/browser/trunk/Tools/Scripts/run-webkit-app
WebKit 目前有一个脚本可以为您执行此操作,称为 run-webkit-app。见http://trac.webkit.org/browser/trunk/Tools/Scripts/run-webkit-app