Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to link against frameworks that are not in the standard location?

Tags:

macos

rust

I tried to link against a private framework in /System/Library/PrivateFrameworks using

#[link(name = "MultitouchSupport", kind = "framework")]

But the linker tells me that the MultitouchSupport framework was not found. I also tried

#[link(name = "/System/Library/PrivateFrameworks/MultitouchSupport", kind = "framework")]

and

#[link(name = "/System/Library/PrivateFrameworks/MultitouchSupport.framework", kind = "framework")]

with the file extension, but neither work.

Is it even possible to link against frameworks that are not in the standard location of /System/Library/Frameworks?

like image 547
jonas-k Avatar asked Mar 24 '16 13:03

jonas-k


People also ask

How do I use frameworks in Xcode?

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.

What are frameworks in Xcode?

A framework is a hierarchical directory that encapsulates shared resources, such as a dynamic shared library, nib files, image files, localized strings, header files, and reference documentation in a single package. Multiple applications can use all of these resources simultaneously.


1 Answers

I found out that WiSaGaN's suggestion was quite close to the solution: It works if you use search=framework in the build.rs. The solution was to use the following build.rs:

fn main()
{
    println!("cargo:rustc-link-search=framework={}", "/System/Library/PrivateFrameworks");
}

Thank you, WiSaGaN!

Using this build.rs you can link as usual:

#[link(name = "MultitouchSupport", kind = "framework")]
like image 117
jonas-k Avatar answered Oct 28 '22 00:10

jonas-k