Skip to content

How to link struct from framework? #115

Open
@KSBilodeau

Description

@KSBilodeau

I'm currently attempting to call the controllers functions as seen here in order to get a list of connected controllers on mac. I'm attempting to achieve this with the following code:

use objc::{class, msg_send, sel, sel_impl};
use objc::runtime::{BOOL, Object};

fn main() {
    unsafe {
        let class = class!(GCController);
        let selector = sel!(controllers);
        let obj: *mut Object = msg_send![class, new];

        let _: *mut Object = msg_send![class, selector];

        // Even void methods must have their return type annotated
        let _: () = msg_send![obj, release];
    }
}

However, it fails as follows:

thread 'main' panicked at 'Class with name GCController could not be found', src/main.rs:6:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2f3ddd9f594adf9773547aa7cedb43c4ac8ffd2f/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/2f3ddd9f594adf9773547aa7cedb43c4ac8ffd2f/library/core/src/panicking.rs:142:14
   2: objc_test::main
             at ./src/main.rs:6:21
   3: core::ops::function::FnOnce::call_once
             at /rustc/2f3ddd9f594adf9773547aa7cedb43c4ac8ffd2f/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

How do I link against the Controllers framework to get this to work? Also, any advice for calling functions would be incredibly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions