Post

Replies

Boosts

Views

Activity

Callback is not invoked when a closure callback-style call is executed in XPC
I noticed a problem while writing a program using XPC on macOS. When I write it in the form of a closure that receives the result of an XPC call, I can't receive it forever. I add an XPC target in Xcode, the sample code is used in the pass closure format, but can't I use closure passing with XPC? My Environment: Xcode 15.3 macOS 14.4.1 caller (closure version) struct ContentView: View { @State var callbackResult: String = "Waiting…" var body: some View { Form { Section("Run XPC Call with no argument and no return value using callback") { Button("Run…") { callbackResult = "Running…" let service = NSXPCConnection(serviceName: "net.mtgto.example-nsxpc-throws-error.ExampleXpc") service.remoteObjectInterface = NSXPCInterface(with: ExampleXpcProtocol.self) service.activate() guard let proxy = service.remoteObjectProxy as? any ExampleXpcProtocol else { return } defer { service.invalidate() } proxy.performCallback { callbackResult = "Done" } } Text(callbackResult) ... } } } callee (closure version) @objc protocol ExampleXpcProtocol { func performCallback(with reply: @escaping () -> Void) } class ExampleXpc: NSObject, ExampleXpcProtocol { @objc func performCallback(with reply: @escaping () -> Void) { reply() } } I found this problem can be solved by receiving asynchronous using Swift Concurrency. caller (async version) struct ContentView: View { @State var callbackResult: String = "Waiting…" var body: some View { Form { Section("Run XPC Call with no argument and no return value using callback") { Button("Run…") { simpleAsyncResult = "Running…" Task { let service = NSXPCConnection(serviceName: "net.mtgto.example-nsxpc-throws-error.ExampleXpc") service.remoteObjectInterface = NSXPCInterface(with: ExampleXpcProtocol.self) service.activate() guard let proxy = service.remoteObjectProxy as? any ExampleXpcProtocol else { return } defer { service.invalidate() } await proxy.performNothingAsync() simpleAsyncResult = "DONE" } Text(simpleAsyncResult) ... } } } callee (async version) @objc protocol ExampleXpcProtocol { func performNothingAsync() async } class ExampleXpc: NSObject, ExampleXpcProtocol { @objc func performNothingAsync() async {} } To simplify matters, I write source code that omits the arguments and return value, but it is not also invoked by using callback style. All sample codes are available in https://github.com/mtgto/example-nsxpc-throws-error
2
0
658
Apr ’24
Installer.app asks permission before writing App Sandbox Data Container since macOS 14 Sonoma
I found my pkg installer while writing to Data Container in App Sandbox since macOS 14 Sonoma. What is wrong with my installer? My pkg will install file to App Sandbox Container. (Destination Path: "~/Library/Containers/net.mtgto.inputmethod.macSKK/Data/Documents/Dictionaries/SKK-JISYO.L") But I found Installer always asks that “Installer” would like to access data from other apps. Keeping app data separate makes it easier to manage your privacy and security. Click "Don't Allow" button and Installer.app says "The installation failed". This dialog is not shown macOS 13 Ventura. So it seems to relate App Sandbox changes in macOS 14: https://developer.apple.com/documentation/security/app_sandbox/accessing_files_from_the_macos_app_sandbox Is there a way to write to App Sandbox Container from pkg? For detail: https://github.com/mtgto/macSKK/issues/54 Also you can download installer from https://github.com/mtgto/macSKK/releases/tag/0.9.1 (pkg file is exists in macSKK-0.9.1.dmg)
5
0
1.5k
Oct ’23
Sometime sign in form and also native auth view are shown in Sign in with Apple JS
I use Sign in with Apple JS to show sign in button. I found both Apple ID sign-in form and native authenticate view are shown when tap the sign in button several times. Please check it from Screenshot - https://developer.apple.com/forums/content/attachment/f4a5711a-21e1-4897-842d-1f759974b31b NOTE: I don't trouble with it, I only report such a strange situation.
0
0
348
Jun ’20
How to localize (l10n) button of Sign in with Apple JS
Is there official method to localize caption of button generated by "Sign in with Apple JS"?I figure out the button generated by "Sign in with Apple JS" always has English caption "Sign in with Apple"https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/configuring_your_webpage_for_sign_in_with_appleBy the way, "Sign in with Apple JS" URL has "en_US".https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.jschange it to "ja_JP", generated localized caption correctly.https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/ja_JP/appleid.auth.jsBut I don't find official way to localize caption of button.Is it a true way? or another way exists?I also tried:- set "lang" attribute in <html> tag
1
0
585
Jun ’20