diff --git a/.changes/macos-secure-coding.md b/.changes/macos-secure-coding.md new file mode 100644 index 00000000..272b2e31 --- /dev/null +++ b/.changes/macos-secure-coding.md @@ -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. diff --git a/src/platform_impl/macos/app_delegate.rs b/src/platform_impl/macos/app_delegate.rs index 8cb6c009..6beea942 100644 --- a/src/platform_impl/macos/app_delegate.rs +++ b/src/platform_impl/macos/app_delegate.rs @@ -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}, @@ -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()) @@ -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 +}