From 036422da12c5c5d492c87459509fffbd085767c1 Mon Sep 17 00:00:00 2001 From: Josh Kaplan Date: Thu, 28 Apr 2022 19:03:53 +1200 Subject: [PATCH 1/2] Improves documentation --- Sources/SecureXPC/Server/XPCMachServer.swift | 4 ++-- Sources/SecureXPC/Server/XPCServer.swift | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Sources/SecureXPC/Server/XPCMachServer.swift b/Sources/SecureXPC/Server/XPCMachServer.swift index 357d72f..f7052a8 100644 --- a/Sources/SecureXPC/Server/XPCMachServer.swift +++ b/Sources/SecureXPC/Server/XPCMachServer.swift @@ -232,8 +232,8 @@ extension XPCMachServer { // Enables a helper tool in the main app bundle’s Contents/Library/LoginItems directory. func validatePathComponent(_ path: URL, expectedLastComponent: String) throws -> URL { if path.lastPathComponent != expectedLastComponent { - let message = "A login item helper tool must be located within the main app bundle's " + - "Contents/Library/LoginItems directory.\n" + + let message = "A login item must be located within the main app bundle's Contents/Library/LoginItems " + + "directory.\n" + "Expected path component: \(expectedLastComponent)\n" + "Actual path component: \(path.lastPathComponent)" throw XPCError.misconfiguredLoginItem(message) diff --git a/Sources/SecureXPC/Server/XPCServer.swift b/Sources/SecureXPC/Server/XPCServer.swift index 7d3562e..baf0077 100644 --- a/Sources/SecureXPC/Server/XPCServer.swift +++ b/Sources/SecureXPC/Server/XPCServer.swift @@ -623,8 +623,8 @@ extension XPCServer { /// /// This function may successfully be called by both sandboxed and non-sandboxed login items. If this is a sandboxed login item, the /// [`com.apple.security.application-groups`](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_application-groups) - /// entitlement must be present and one of the application groups must have a team identifier matching this login item's helper tool. Both sandboxed and - /// non-sandboxed apps must have a team identifier. + /// entitlement must be present and one of the application groups must have the same team identifier as this login item. Both sandboxed and non-sandboxed + /// apps must have a team identifier. /// /// Incoming requests will only be accepted from the main app or helper tools contained within the main app bundle. Additionally they must have the same team /// identifier as this login item. @@ -667,8 +667,7 @@ extension XPCServer { /// error handler has been set then it is called with ``XPCError/insecure``. /// /// - Parameters: - /// - named: The name of the Mach service this server should bind to. This name must be present in the launchd property list's `MachServices` entry - /// or be implicitly registered by LaunchServices. + /// - named: The name of the Mach service this server should bind to. /// - clientRequirements: If a request is received from a client, it will only be processed if it meets one (or more) of these requirements. /// - Throws: ``XPCError/conflictingClientRequirements`` if a server for this named service has previously been retrieved with different client /// requirements. From 62201b8abcb6fb3313d40117d5ef13f631efe37a Mon Sep 17 00:00:00 2001 From: Josh Kaplan Date: Thu, 28 Apr 2022 19:07:53 +1200 Subject: [PATCH 2/2] Further documentation improvements --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c68c417..1def794 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,9 @@ There are multiple types of servers which can be retrieved: [`SMJobBless`](https://developer.apple.com/documentation/servicemanagement/1431078-smjobbless) - To see a sample app for this use case, check out [SwiftAuthorizationSample](https://github.com/trilemma-dev/SwiftAuthorizationSample) + - `XPCServer.forThisLoginItem()` + - For a login item installed with + [`SMLoginItemSetEnabled`](https://developer.apple.com/documentation/servicemanagement/1501557-smloginitemsetenabled) - `XPCServer.forThisMachService(named:clientRequirements:)` - For [Launch Daemons and Agents](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html) @@ -89,7 +92,8 @@ There are multiple types of clients which can be retrieved: - This corresponds to servers created with `XPCServer.forThisXPCService()` - `XPCClient.forMachService(named:)` - For communicating with an XPC Mach service - - This corresponds to servers created with `XPCServer.forThisBlessedHelperTool()` or + - This corresponds to servers created with `XPCServer.forThisBlessedHelperTool()`, + `XPCServer.forThisLoginItem()`, and `XPCServer.forThisMachService(named:clientRequirements:)` - `XPCClient.forEndpoint(_:)` - This is the only way to communicate with an anonymous server