Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unstable-no-link feature #525

Closed
wants to merge 9 commits into from

Conversation

xiaopengli89
Copy link

Some frameworks may only be available on higher OS versions and some applications want to check at runtime, for example:

// Load MetalFX.framework
if AnyClass::get("MTLFXSpatialScalerDescriptor").is_none() {
    let path = ns_string!("/System/Library/Frameworks/MetalFX.framework");
    let Some(metal_fx_bundle) = NSBundle::bundleWithPath(path) else {
        println!("MetalFX.framework not found");
        return;
    };
    if !metal_fx_bundle.load() {
        println!("Load MetalFX.framework failed");
        return;
    }
}

Copy link
Owner

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've been wanting this feature

crates/icrate/Cargo.toml Outdated Show resolved Hide resolved
crates/icrate/Cargo.toml Outdated Show resolved Hide resolved
@xiaopengli89 xiaopengli89 changed the title Add link feature Add no-link-* features Nov 1, 2023
crates/icrate/Cargo.toml Outdated Show resolved Hide resolved
@xiaopengli89 xiaopengli89 changed the title Add no-link-* features Add unstable-no-link feature Dec 5, 2023
@madsmtm
Copy link
Owner

madsmtm commented Dec 5, 2023

Ok, last thing, promise this time:

Can your use-case be solved by -weak_framework MetalFX instead? E.g. is it enough to add the following to your crate (using a nightly from this week):

#![feature(link_arg_attribute)]

#[link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim")]
#[link(name = "MetalFX", kind = "link-arg", modifiers = "+verbatim")]
extern "C" {}

@xiaopengli89
Copy link
Author

Ok, last thing, promise this time:

Can your use-case be solved by -weak_framework MetalFX instead? E.g. is it enough to add the following to your crate (using a nightly from this week):

#![feature(link_arg_attribute)]

#[link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim")]
#[link(name = "MetalFX", kind = "link-arg", modifiers = "+verbatim")]
extern "C" {}

Yeah, it works. I'll close the pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants