How to link to a specific framework version in Xcode?

扶醉桌前 提交于 2019-12-09 12:22:51

问题


I've got an application that links against OS X's Python.framework. Since Snow Leopard has upgraded to Python 2.6, the framework now contains versions for 2.4, 2.5, and 2.6. My program doesn't seem to want to link against 2.6, though, and this ends up causing errors when I try and use features from the newer Python runtime.

I know I can just use install_name_tool to change the linking in a post-build step, but is there any way to simply tell it where to link during the build? Seems like a pretty common use case.


回答1:


I have not tried this, but I believe it will work.

1) Do NOT add the framework to your Xcode project

2) Instead, use the full path to the library in "OTHER_LINKER_FLAGS" - so "/System/Library/Frameworks/Python.framework/2.5/Python"

3) You'll also want to set the framework search path to "/System/Library/Frameworks/Python.framework/2.5/" and set the include search path to "/System/Library/Frameworks/Python.framework/2.5/Headers"

However, with all that said, it will leave you vulnerable to any changes Apple may make. For example, everything will break if they later remove 2.5 from the framework. It'd be a much better idea to just update your app to work with the current version of Python.




回答2:


I had this specific problem, too, and couldnt find a way to get Python Framework 2.6 in the build.

I couldn't get the OTHER_LINKER_FLAGS approach to work, alas.

So, like SJML suggested, I used a post build step like so:

#
# Force the required version of Python to be 2.6
# dvb10.12.01

install_name_tool \
    -change \
        /System/Library/Frameworks/Python.framework/Versions/2.5/Python \
        /System/Library/Frameworks/Python.framework/Versions/2.6/Python \
    $TARGET_BUILD_DIR/omino_python.plugin/Contents/MacOS/omino_python

Just putting it out there for the grepping. :)



来源:https://stackoverflow.com/questions/2414807/how-to-link-to-a-specific-framework-version-in-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!