Post

Replies

Boosts

Views

Activity

`listener failed to activate: xpc_error=[1: Operation not permitted]`
Hi :wave: I started a new project to experiment with EndpointSecurity framework. It seems to have been worked, but when I try to add XPC I face some troubles. I am not able to send XPC message from my app to my system extension. No runtime error, but when I'm inspecting logs: That correspond to this code: https://github.com/tony-go/TestES/blob/main/Extension/main.swift#L21-L30 Full project: https://github.com/tony-go/TestES/ I thought at first that it could come from a missing @objc somehere but it does not seems ... I also wonder why I cannot catch this error at runtime ?
12
0
1.2k
May ’24
How to conform Swift class to C++ header
Hi People :) I'm experimenting with Swift/C++ interoperability these days. I'd like to understand how could I conform a Swift class to Cxx header: Like this: import Application class App: Application { public func run() { let app = NSApplication.shared let delegate = AppDelegate() app.delegate = delegate app.run() } } But I got this error: /Users/tonygo/oss/native-research/App.swift:27:7: error: inheritance from non-protocol, non-class type 'Application' class App: Application { ^ ninja: build stopped: subcommand failed. That seems normal indeed. Reproductible example: https://github.com/tony-go/native-research/tree/conform-swift-to-cxx-header (Just run make) I also have another branch on that repo where I use an intermediate Cxx bridge file that conforms to the :Application class and use the Swift API, like this: https://github.com/tony-go/native-research/tree/main/app Bit I think that its a lot of boilerplate. So I wonder which approach could I take for this? Cheers :)
3
0
491
May ’24
Setup LaunchAgent in Xcode
Hi there :) I try to put an Xcode project in place within a LaunchAgent. The ultimate goal is to have an "application" with two component: macOS application with just an basic UI all the logic happens in a LaunchAgent that runs on background and is launch at startup. The macOS app uses XPC to send messages to the agent that will run either the app is opened or not. I struggled at first having this error (for the agent): An XPC Service cannot be run directly. Then I found using MachServices key in the .plist of the agent fixes the issue, plus: let listener = NSXPCListener.init(machServiceName: "com.tonygo.NetworkMonitorAgent") Then I wonder: Do we have somewhere a documentation about how to setup a LaunchAgent in Xcode I create the plist of the agent on side and run it manually, I could do this in a more automatic way How could I package a macOS applciation that will contains the agent, install it and load the agent? Note: This is mainly for learning and understanding what we could do at each level (XPCService, LaunchAgents, LaunchDaemon, etc.).
23
0
2.5k
Jan ’24
Using `SecCodeCopyGuestWithAttributes` with auditToken results in `100001 - UNIX[Operation not permitted]`
Hi everyone :) I'm exploring XPC these days; more specifically, I'm trying to establish a connection between a macOS application and an XPC service. I succeeded in establishing the connection, but now I'm trying to verify the incoming connection by using SecCodeCopyGuestWithAttributes, passing it an audit token. But I got the following error: 2024-01-18 10:43:06.805435+0100 DemoService[1627:7118397] [logging-persist] cannot open file at line 46922 of [554764a6e7] 2024-01-18 10:43:06.805452+0100 DemoService[1627:7118397] [logging-persist] os_unix.c:46922: (0) open(/private/var/db/DetachedSignatures) - Undefined error: 0 Cannot get SecCode: 100001 - UNIX[Operation not permitted] Audit token: Optional(32 bytes) The last two lines come from my code: class XPCClientValidator { var secCodeOptional: SecCode? = nil; func identifyGuest(for connection: NSXPCConnection) -> Bool { let auditToken = AuditToken.extractToken(from: connection) let hostSecCode: SecCode? = nil; // This is a way to indicate that the code signing root of trust hould be used as host. let attributes = [ kSecGuestAttributeAudit: auditToken ] as CFDictionary let secFlags = SecCSFlags(rawValue: 0) // Asks a code host to identify the guest given the audit token let status: OSStatus = SecCodeCopyGuestWithAttributes(hostSecCode, attributes, secFlags, &self.secCodeOptional) if (status != errSecSuccess) { let msg = SecCopyErrorMessageString(status, nil)! print("Cannot get SecCode: \(status) - \(msg)") print("Audit token: \(String(describing: auditToken))") return false } guard let _ = secCodeOptional else { NSLog("Couldn't unwrap the secCode") return false } return true } } I saw a few posts on the forum, but nothing helped me to solve this issue. The complete source code is here: https://github.com/tony-go/XPCDemo/tree/secure-xpc Note: If you want to reproduce it, you have to: start the app type a random input click on "uppercase it"
5
0
927
Jan ’24
Impossible to use $R* variables after `continue` command
I’m trying to use the allocated variables given after p self ($R1 for instance) but after resuming the process and then pausing it again, I cannot access to $R1. (lldb) p self (Signals.MainContainerViewController) $R1 = 0x000000012ba19dc0 { ... (lldb) po $R1 <Signals.MainContainerViewController: 0x12ba19dc0> (lldb) c Process 88944 resuming (lldb) expression -O -l swift -- $R1 warning: Module "/usr/lib/system/libsystem_kernel.dylib" uses triple "arm64-apple-macosx13.4.0", which is not compatible with the target triple "arm64-apple-ios16.0.0-simulator". Enabling per-module Swift scratch context. error: expression failed to parse: error: <EXPR>:3:1: error: cannot find '$R1' in scope $R1 ^~~ (lldb) Does someone have an idea? macOS: 13.4.1 (22F82) Xcode Version 14.3.1
5
1
1.5k
Jul ’23
Running `[[UIApplication sharedApplication] openURL:url` into a concurrent thread?
I'm currently working on a feature (cross macOS iOS) that involves the openURL API. [[UIApplication sharedApplication] openURL:url for iOS [[NSWorkspace sharedWorkspace] openURL:url for macOS I used the signature for both APIs that affords me the completionHandler callback. Documentations point out that the iOS version callback run on the main thread and the other one on a concurrent one. I don't know if some of you know why we have this distinction. I found a piece of code from the Chrome codebase, where dispatch_async is used for the older versions of iOS: https://cs.github.com/hbtlabs/chromium-white-flash-fix/blob/e890904e9fc7a18c813772ffcbbdef9c3cf6af4d/ios/chrome/browser/open_url_util.mm?q=%5B%5BUIApplication+sharedApplication%5D+openURL%3Aurl#L13 Should I run the callback into another thread with dispatch_async as I see there? https://cs.github.com/microsoft/WinObjC/blob/94f6b5bfdc09d945e30607b56124b6f94a5b9d7b/Frameworks/SafariServices/SFSafariWebViewController.mm?q=%5B%5BUIApplication+sharedApplication%5D+openURL%3Aurl#L99-L109 Thanks ^^
0
0
692
Apr ’23