Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link to a specific framework version in Xcode?

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.

like image 273
SJML Avatar asked Mar 10 '10 05:03

SJML


People also ask

How do I add a framework in Xcode 13?

To include a framework in your Xcode project, choose Project > Add to Project and select the framework directory. Alternatively, you can control-click your project group and choose Add Files > Existing Frameworks from the contextual menu.

How do I open framework in Xcode?

Xcode has a tendancy to select the "openFrameworks" scheme instead of the one you actually want (which is your app). Select the dropdown in the top which says "openFrameworks" and set it to your app's name. If you find that you try to run your app and nothing happens, this is almost always the reason.

How do I add a framework to a swift project?

So select your iOS App and then select the target you want to link with. Then go to the General tab and click (+) in Frameworks, Libraries, and Embedded Content section, then select your framework and click Add. Link the framework to the app. Voilá!


1 Answers

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.

like image 170
wadesworld Avatar answered Nov 15 '22 05:11

wadesworld