I am trying to learn by doing a project of allowing AppKit certain functions , related with App and Window creation to be called from Rust using objc.
extern crate objc;
use objc::runtime::{Class,Object};
use objc::{msg_send, sel, sel_impl};
pub fn create_app(){
unsafe {
let app_class =Class::get("NSApplication").unwrap();
let app:&Object = msg_send![app_class,sharedApplication];
let _:&Object = msg_send![app_class,run];
}
}
However if i try to run this an main.rs I get the following:
thread 'main' panicked at src/lib.rs:7:52:
called `Option::unwrap()` on a `None` value
I guess the objective-c is unable to find the NSApplication Class of AppKit but why and how can i resolve such an issue?
I am running all of this from a M3 MacOs just to give insight on my machine.
extern crate
is redundant in modern versions of Rust.objc
appears abandoned, last commit 4 years ago. Maybe the author just considers it complete, but consider switching to a different crate, probablyobjc2
.class!()
macro, does it work?