Skip to content

Commit

Permalink
fix(macos): Enable applicationSupportsSecureRestorableState = YES (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjmallon authored Nov 28, 2023
1 parent 499e492 commit 5eb2124
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/macos-secure-coding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tao": patch
---

Enable macOS secure state restoration on OS versions that support it. This avoids
'WARNING: Secure coding is not enabled for restorable state!' on macOS Sonoma.
12 changes: 11 additions & 1 deletion src/platform_impl/macos/app_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use cocoa::base::id;
use cocoa::foundation::NSString;
use objc::{
declare::ClassDecl,
runtime::{Class, Object, Sel},
runtime::{Class, Object, Sel, BOOL},
};
use std::{
cell::{RefCell, RefMut},
Expand Down Expand Up @@ -54,6 +54,10 @@ lazy_static! {
sel!(application:openURLs:),
application_open_urls as extern "C" fn(&Object, Sel, id, id),
);
decl.add_method(
sel!(applicationSupportsSecureRestorableState:),
application_supports_secure_restorable_state as extern "C" fn(&Object, Sel, id) -> BOOL,
);
decl.add_ivar::<*mut c_void>(AUX_DELEGATE_STATE_NAME);

AppDelegateClass(decl.register())
Expand Down Expand Up @@ -120,3 +124,9 @@ extern "C" fn application_open_urls(_: &Object, _: Sel, _: id, urls: id) -> () {
AppState::open_urls(urls);
trace!("Completed `application:openURLs:`");
}

extern "C" fn application_supports_secure_restorable_state(_: &Object, _: Sel, _: id) -> BOOL {
trace!("Triggered `applicationSupportsSecureRestorableState`");
trace!("Completed `applicationSupportsSecureRestorableState`");
objc::runtime::YES
}

0 comments on commit 5eb2124

Please sign in to comment.