ryanmcgrath / cacao

Rust bindings for AppKit (macOS) and UIKit (iOS/tvOS). Experimental, but working!
MIT License
1.85k stars 69 forks source link

Could not compile user-notifications feature. #23

Open PfisterFactor opened 2 years ago

PfisterFactor commented 2 years ago

Compiling below (cargo build):

# Cargo.toml
[dependencies]
cacao = {version = "0.2.1", features = ["user-notifications"]}
// main.rs
use cacao::macos::{App, window::Window, AppDelegate};
use cacao::notification_center;

#[derive(Default)]
struct BasicApp {
    window: Window
}

impl AppDelegate for BasicApp {
    fn did_finish_launching(&self) {
        self.window.set_minimum_content_size(400., 400.);
        self.window.set_title("Hello World!");
        self.window.show();

    }
}

fn main() {
    App::new("com.hello.world", BasicApp::default()).run();
}

leads to the following errors:

❯ cargo build
   Compiling cacao v0.2.1
error[E0599]: no function or associated item named `wrap` found for struct `NSString<'_>` in the current scope
  --> /Users/ej/.cargo/registry/src/github.com-1ecc6299db9ec823/cacao-0.2.1/src/user_notifications/mod.rs:29:55
   |
29 |                 let localized_description = NSString::wrap(msg_send![error, localizedDescription]); 
   |                                                       ^^^^ function or associated item not found in `NSString<'_>`
   |
  ::: /Users/ej/.cargo/registry/src/github.com-1ecc6299db9ec823/cacao-0.2.1/src/foundation/string.rs:19:1
   |
19 | pub struct NSString<'a> {
   | ----------------------- function or associated item `wrap` not found for this

For more information about this error, try `rustc --explain E0599`.
error: could not compile `cacao` due to previous error

I am on a M1 Macbook Pro (2021, 14-inch) running MacOS Monterey using stable-aarch64-apple-darwin. stable-x86_64-apple-darwin produces the same result.

PfisterFactor commented 2 years ago

Of note that building with the "airyx-appkit-uikit-features" (and changing to the appkit module) fixed this error

[dependencies]
cacao = {git = "https://github.com/ryanmcgrath/cacao.git", branch="airyx-appkit-uikit-features", features = ["user-notifications"]}
ryanmcgrath commented 2 years ago

Yup, there’s an open issue for that already. I just threw their change into the new branch, need to merge and release at some point here.

Also note that this requires signing your code for notifications to work - if you can’t or don’t want to do that then rust notify supports the older API.

On Thu, Jan 13, 2022 at 15:30, Eric Pfister @.***> wrote:

Of note that building with the "airyx-appkit-uikit-features" fixed this error.

[

dependencies

]

cacao

= {

git

=

"

https://github.com/ryanmcgrath/cacao.git

"

,

branch

=

"

airyx-appkit-uikit-features

"

,

features

= [

"

user-notifications

"

]}

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>