What's New / Connectivity & Hardware

What's new in AccessoryAccess

+11 NewmacOS

AccessoryAccess provides APIs for matching and communicating with USB accessories. It centers on AAUSBAccessoryManager, matching criteria for devices and interfaces, and a listener protocol for accessory events.

The 27 SDK adds 11 APIs, with no deprecations or removals. New types are the AAError struct with its Code and Event enums, the AAUSBAccessoryListener protocol, the InterfaceMatchingOption enum, and the DeviceMatchingCriteria and InterfaceMatchingCriteria structs. New symbols include AAErrorDomain, AAUSBAccessoryManager.events, and AAUSBAccessoryMatchingCriteria.init.

New

11
struct

AAError

NewmacOS
public struct AAError : CustomNSError, Hashable, Error
Declaration
public struct AAError : CustomNSError, Hashable, Error {

    public init(_nsError: NSError)

    public static var errorDomain: String { get }

    /**
     @enum AAErrorCode
     @abstract
        Error type returned by the AccessoryAccess framework.
        The `NSError` domain is `AAErrorDomain`, the code is one of the `AAErrorCode` constants.
    
        The AccessoryAccess framework can also report errors from other domains when the error originates from a lower level component.
    
     @constant AAErrorCodeInternal
        An internal error.
     @constant AAErrorCodeAccessoryListenerAlreadyRegistered
        The accessory listener is already registered, and therefore cannot be re-registered.
     @constant AAErrorCodeAccessoryNotAccessible
        The accessory is not accessible since it may already be in use.
     @constant AAErrorCodeInvalidAccessoryState
        API used when the accessory is not in the correct state.
     */
    @available(macOS 27.0, *)
    public enum Code : Int, @unchecked Sendable, Equatable {

        /**
         @enum AAErrorCode
         @abstract
            Error type returned by the AccessoryAccess framework.
            The `NSError` domain is `AAErrorDomain`, the code is one of the `AAErrorCode` constants.
        
            The AccessoryAccess framework can also report errors from other domains when the error originates from a lower level component.
        
         @constant AAErrorCodeInternal
            An internal error.
         @constant AAErrorCodeAccessoryListenerAlreadyRegistered
            The accessory listener is already registered, and therefore cannot be re-registered.
         @constant AAErrorCodeAccessoryNotAccessible
            The accessory is not accessible since it may already be in use.
         @constant AAErrorCodeInvalidAccessoryState
            API used when the accessory is not in the correct state.
         */
        public typealias _ErrorType = AAError

        case internalError = 1

        case accessoryListenerAlreadyRegistered = 2

        case accessoryNotAccessible = 3

        case invalidAccessoryState = 4
    }

    public static var internalError: AAError.Code { get }

    public static var accessoryListenerAlreadyRegistered: AAError.Code { get }

    public static var accessoryNotAccessible: AAError.Code { get }

    public static var invalidAccessoryState: AAError.Code { get }
}
let

AAErrorDomain

NewmacOS
public let AAErrorDomain: String
protocol

AAUSBAccessoryListener

NewmacOS
public protocol AAUSBAccessoryListener : NSObjectProtocol, Sendable
Declaration
public protocol AAUSBAccessoryListener : NSObjectProtocol, Sendable {

    /**
     @abstract Invoked when a USB accessory connects to the system.
     @discussion
        This method is invoked every time a USB accessory, that satisfies the matching criteria this listener registered with `AAUSBAccessoryManager`
        with, is connected to the system.
    
        This method will be invoked on an arbitrary thread.
     @param usbAccessory The USB accessory that connected to the system.
     @see AAUSBAccessoryMatchingCriteria
     @see AAUSBAccessoryManager
     */
    optional func usbAccessoryDidConnect(_ usbAccessory: AAUSBAccessory)

    /**
     @abstract Invoked when a USB accessory disconnects from the system.
     @discussion
        This method is invoked every time a USB accessory, for which the listener received the connect notification or was already connected at the
        time of listener registration, is disconnected from the system.
    
        This method will be invoked on an arbitrary thread.
     @param usbAccessory The USB accessory that disconnected from the system.
     @see AAUSBAccessoryMatchingCriteria
     @see AAUSBAccessoryManager
     */
    optional func usbAccessoryDidDisconnect(_ usbAccessory: AAUSBAccessory)
}
enum

AAError.Code

NewmacOS
public enum Code : Int, @unchecked Sendable, Equatable
Declaration
public enum Code : Int, @unchecked Sendable, Equatable {

    /**
     @enum AAErrorCode
     @abstract
        Error type returned by the AccessoryAccess framework.
        The `NSError` domain is `AAErrorDomain`, the code is one of the `AAErrorCode` constants.
    
        The AccessoryAccess framework can also report errors from other domains when the error originates from a lower level component.
    
     @constant AAErrorCodeInternal
        An internal error.
     @constant AAErrorCodeAccessoryListenerAlreadyRegistered
        The accessory listener is already registered, and therefore cannot be re-registered.
     @constant AAErrorCodeAccessoryNotAccessible
        The accessory is not accessible since it may already be in use.
     @constant AAErrorCodeInvalidAccessoryState
        API used when the accessory is not in the correct state.
     */
    public typealias _ErrorType = AAError

    case internalError = 1

    case accessoryListenerAlreadyRegistered = 2

    case accessoryNotAccessible = 3

    case invalidAccessoryState = 4
}
enum

AAUSBAccessory.Event

NewmacOS
public enum Event : Sendable
Declaration
public enum Event : Sendable {

    case didConnect(AAUSBAccessory)

    case didDisconnect(AAUSBAccessory)
}
func

AAUSBAccessoryManager.events

NewmacOS
public func events(matching criteria: [AAUSBAccessoryMatchingCriteria]) async throws -> some AsyncSequence<AAUSBAccessory.Event, Never>
struct

AAUSBAccessoryMatchingCriteria.DeviceMatchingCriteria

NewmacOS
public struct DeviceMatchingCriteria : Sendable
Declaration
public struct DeviceMatchingCriteria : Sendable {

    public var vendorID: Int?

    public var productID: Int?

    public var deviceClass: Int?

    public var deviceSubClass: Int?

    public var deviceProtocol: Int?

    public var speed: Int?

    public init(vendorID: Int? = nil, productID: Int? = nil, deviceClass: Int? = nil, deviceSubClass: Int? = nil, deviceProtocol: Int? = nil, speed: Int? = nil)
}
init

AAUSBAccessoryMatchingCriteria.init

NewmacOS
public convenience init(deviceMatchingCriteria: AAUSBAccessoryMatchingCriteria.DeviceMatchingCriteria)
init

AAUSBAccessoryMatchingCriteria.init

NewmacOS
public convenience init(deviceMatchingCriteria: AAUSBAccessoryMatchingCriteria.DeviceMatchingCriteria?, interfaceMatchingCriteria: [AAUSBAccessoryMatchingCriteria.InterfaceMatchingCriteria], interfaceMatchingOption: AAUSBAccessoryMatchingCriteria.InterfaceMatchingOption)
struct

AAUSBAccessoryMatchingCriteria.InterfaceMatchingCriteria

NewmacOS
public struct InterfaceMatchingCriteria : Sendable
Declaration
public struct InterfaceMatchingCriteria : Sendable {

    public var vendorID: Int?

    public var productID: Int?

    public var bcdDevice: Int?

    public var interfaceNumber: Int?

    public var configurationValue: Int?

    public var interfaceClass: Int?

    public var interfaceSubClass: Int?

    public var interfaceProtocol: Int?

    public var speed: Int?

    public init(vendorID: Int? = nil, productID: Int? = nil, bcdDevice: Int? = nil, interfaceNumber: Int? = nil, configurationValue: Int? = nil, interfaceClass: Int? = nil, interfaceSubClass: Int? = nil, interfaceProtocol: Int? = nil, speed: Int? = nil)
}
enum

AAUSBAccessoryMatchingCriteria.InterfaceMatchingOption

NewmacOS
public enum InterfaceMatchingOption : Int, @unchecked Sendable
Declaration
public enum InterfaceMatchingOption : Int, @unchecked Sendable {

    /** Matching is successful for the USB accessory that has at least one USB interface matching every criteria/dictionary. */
    case matchAll = 0

    /** Matching is successful for the USB accessory that has at least one USB interface matching any of the criteria/dictionaries. */
    case matchAny = 1
}

No APIs match your filter.

← More in Connectivity & Hardware