Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode - Linking against ApplicationServices.framework with SDK 10.9 causes 10.7 incompatibilites

I'm having trouble running a Cocoa app on 10.7 even though it seems like I'm taking the correct steps. Here's a description of what I'm doing and what seems to be wrong:

I'm building on a 10.8 machine with XCode 5.0.2 and SDK 10.9 with a deployment target of 10.7. One of my dynamic libraries uses some CoreGraphics functions, so I linked that library against ApplicationServices.framework. (From what I understand, prior to 10.8, CoreGraphics was included within ApplicationServices, so I can't link against CoreGraphics directly or I'll have problems.)

After building, my library that uses CoreGraphics has references directly to CoreGraphics.framework at /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics, but that path doesn't exist on 10.7. When I run the application on 10.8+, it works fine, but on 10.7, it blows up trying to load that framework that doesn't exist.

My (hacky) Solution:

After banging my head against this for a while, I decided to go nuclear and add a new Build Phase to change the CoreGraphics reference in my library to a path that is compatible with 10.7, beneath ApplicationServices.framework. My script does the following:

install_name_tool -change /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics myLibrary.dylib

This works, but it seems like a silly hack. Has anyone else seen this?

like image 380
Will K Avatar asked Nov 26 '13 01:11

Will K


1 Answers

You have to test it, but maybe it is enough to just link against ApplicationServices.framework.

Otherwise you should be able to get it working with weak linking: In the Link Binary with Libraries Build Phase, change the Status from Required to Optimal. More details about weak linking can be found here.

like image 192
catlan Avatar answered Nov 12 '22 01:11

catlan