Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ on:
jobs:
test:
name: Test
runs-on: macOS-14
runs-on: macOS-26
env:
DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_26.0.app/Contents/Developer
strategy:
matrix:
destination:
- "platform=macOS"
- "platform=iOS Simulator,name=iPhone 14"
- "platform=iOS Simulator,name=iPhone 17"
steps:
- uses: actions/checkout@v4
- name: Test platform ${{ matrix.destination }}
Expand Down
8 changes: 0 additions & 8 deletions Sources/Extendable/ConnectableConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@

private var handler: @MainActor (NSXPCConnection) -> Bool

@available(macOS 15.0, iOS 26, *)
@MainActor @preconcurrency
public init(
onSessionRequest requestHandler: @escaping @Sendable (XPCListener.IncomingSessionRequest) -> XPCListener.IncomingSessionRequest.Decision
) {
preconditionFailure()
}

@MainActor @preconcurrency
public init(onConnection connectionHandler: @escaping @Sendable (NSXPCConnection) -> Bool) {
self.handler = connectionHandler
Expand All @@ -21,7 +13,7 @@

nonisolated public func accept(connection: NSXPCConnection) -> Bool {
MainActor.assumeIsolated {
handler(connection)

Check warning on line 16 in Sources/Extendable/ConnectableConfiguration.swift

View workflow job for this annotation

GitHub Actions / Test (platform=iOS Simulator,name=iPhone 17)

sending 'connection' risks causing data races; this is an error in the Swift 6 language mode
}
}
}
18 changes: 14 additions & 4 deletions Sources/Extendable/ConnectableExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,39 @@
public struct ConnectingAppExtensionConfiguration: AppExtensionConfiguration {
let accepter: ConnectionAccepter

public init(_ handler: @escaping ConnectionHandler) {
public init(_ handler: @escaping ExtendableConnectionHandler) {
self.accepter = ConnectionAccepter(handler)
}

public func accept(connection: NSXPCConnection) -> Bool {
return accepter.accept(connection: connection)

Check warning on line 14 in Sources/Extendable/ConnectableExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=macOS)

main actor-isolated property 'accepter' can not be referenced from a nonisolated context

Check warning on line 14 in Sources/Extendable/ConnectableExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=iOS Simulator,name=iPhone 17)

main actor-isolated property 'accepter' can not be referenced from a nonisolated context
}
}


@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public protocol AnyConnectableExtension: AppExtension {}


@available(macOS 26.0, iOS 26.0, *)
public protocol XPCConnectableExtension: AnyConnectableExtension {
var configuration: ConnectionHandler{get}
}

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public protocol ConnectableExtension: AppExtension {
public protocol ConnectableExtension: AnyConnectableExtension {
func acceptConnection(_ connection: NSXPCConnection) throws
}

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public extension ConnectableExtension {
/// The global, per-exension configuration
/// The global, per-extension configuration
///
/// This configuration applies to the extension process, and
/// its connection corresponds to `AppExtensionProcess`. This
/// will be used for the `configuration` property by default.
var globalConfiguration: ConnectingAppExtensionConfiguration {
return ConnectingAppExtensionConfiguration { connection in

Check warning on line 41 in Sources/Extendable/ConnectableExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=macOS)

sending value of non-Sendable type '(NSXPCConnection) throws -> ()' risks causing data races; this is an error in the Swift 6 language mode

Check warning on line 41 in Sources/Extendable/ConnectableExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=macOS)

call to main actor-isolated initializer 'init(_:)' in a synchronous nonisolated context

Check warning on line 41 in Sources/Extendable/ConnectableExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=iOS Simulator,name=iPhone 17)

sending value of non-Sendable type '(NSXPCConnection) throws -> ()' risks causing data races; this is an error in the Swift 6 language mode

Check warning on line 41 in Sources/Extendable/ConnectableExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=iOS Simulator,name=iPhone 17)

call to main actor-isolated initializer 'init(_:)' in a synchronous nonisolated context
try self.acceptConnection(connection)
}
}
Expand All @@ -40,6 +50,6 @@


@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public protocol NewConnectableExtension: AppExtension {
public protocol NewConnectableExtension: ConnectableExtension {
func acceptConnection(_ connection: NSXPCConnection) throws
}
18 changes: 18 additions & 0 deletions Sources/Extendable/ConnectableSceneExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
public extension ConnectableSceneExtension {
var configuration: AppExtensionSceneConfiguration {
return AppExtensionSceneConfiguration(scene, configuration: globalConfiguration)

Check warning on line 20 in Sources/Extendable/ConnectableSceneExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=macOS)

call to main actor-isolated initializer 'init(_:configuration:)' in a synchronous nonisolated context

Check warning on line 20 in Sources/Extendable/ConnectableSceneExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=iOS Simulator,name=iPhone 17)

call to main actor-isolated initializer 'init(_:configuration:)' in a synchronous nonisolated context
}
}


/// Defines an interface between a host and view-based extension.
///
/// This type provides more structure to a view-based extension.
@available(macOS 26.0, iOS 26.0, *)
public protocol XPCConnectableSceneExtension<Content>: XPCConnectableExtension {
associatedtype Content : AppExtensionScene

var scene: Content { get }
}

@available(macOS 26.0, iOS 26.0, *)
public extension XPCConnectableSceneExtension {
var configuration: AppExtensionSceneConfiguration {
return AppExtensionSceneConfiguration(scene, configuration: configuration)

Check warning on line 38 in Sources/Extendable/ConnectableSceneExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=macOS)

call to main actor-isolated initializer 'init(_:configuration:)' in a synchronous nonisolated context

Check warning on line 38 in Sources/Extendable/ConnectableSceneExtension.swift

View workflow job for this annotation

GitHub Actions / Test (platform=iOS Simulator,name=iPhone 17)

call to main actor-isolated initializer 'init(_:configuration:)' in a synchronous nonisolated context
}
}
6 changes: 3 additions & 3 deletions Sources/Extendable/ConnectionAccepter.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Foundation
import os.log

public typealias ConnectionHandler = (NSXPCConnection) throws -> Void
public typealias ExtendableConnectionHandler = (NSXPCConnection) throws -> Void

struct ConnectionAccepter {
private let logger = Logger(subsystem: "com.chimehq.Extendable", category: "ConnectionAccepter")

let handler: ConnectionHandler
let handler: ExtendableConnectionHandler

init(_ handler: @escaping ConnectionHandler) {
init(_ handler: @escaping ExtendableConnectionHandler) {
self.handler = handler
}

Expand Down
Loading