What's New / Storage, System & Virtualization

What's new in XPC

+13 NewiOS · macOS · tvOS · watchOS

XPC is Apple's interprocess communication framework for sending structured messages between processes. It defines typed value containers and serialization for the data passed across process boundaries.

The 27 SDK adds 13 APIs with no deprecations or removals. The new struct XPCLiteralValue builds XPC values from Swift literals and exposes the literal-type aliases StringLiteralType, ExtendedGraphemeClusterLiteralType, UnicodeScalarLiteralType, IntegerLiteralType, and BooleanLiteralType. XPCDictionary and its subscript provide keyed access to dictionary-shaped XPC payloads.

New

13
extension

XPCDictionary

NewiOSmacOStvOSwatchOS
extension XPCDictionary : ExpressibleByDictionaryLiteral
Declaration
extension XPCDictionary : ExpressibleByDictionaryLiteral {

    /// The key type of a dictionary literal.
    public typealias Key = String

    /// The value type of a dictionary literal.
    public typealias Value = XPCLiteralValue

    /// Creates an `XPCDictionary` initialized with the given key-value pairs.
    ///
    /// - Parameters:
    ///   - elements: The key-value pairs that will make up the new dictionary.
    ///               Values can be strings, integers, booleans, floating-point numbers,
    ///               or other XPC-compatible types.
    ///
    /// Example usage:
    /// ```swift
    /// let dict: XPCDictionary = [
    ///     "name": "John",
    ///     "age": 30,
    ///     "isActive": true,
    ///     "score": 95.5
    /// ]
    /// ```
    ///
    /// For more complex types, you can explicitly create XPCLiteralValue:
    /// ```swift
    /// let dict: XPCDictionary = [
    ///     "nested": XPCLiteralValue(anotherDict),
    ///     "endpoint": XPCLiteralValue(someEndpoint)
    /// ]
    /// ```
    public init(dictionaryLiteral elements: (String, XPCLiteralValue)...)
}
struct

XPCLiteralValue

NewiOSmacOStvOSwatchOS
public struct XPCLiteralValue

A type that bridges Swift literal values to XPC objects for use in dictionary literals.

This type enables ergonomic dictionary literal syntax:

let dict: XPCDictionary = [
    "name": "John",
    "age": 30,
    "isActive": true,
    "score": 95.5
]
Declaration
public struct XPCLiteralValue {

    /// Creates an XPCLiteralValue from an xpc_object_t.
    public init(_ object: xpc_object_t)

    /// Creates an XPCLiteralValue from a String.
    public init(_ value: String)

    /// Creates an XPCLiteralValue from a signed integer.
    public init<T>(_ value: T) where T : SignedInteger

    /// Creates an XPCLiteralValue from an unsigned integer.
    public init<T>(_ value: T) where T : UnsignedInteger

    /// Creates an XPCLiteralValue from a floating-point number.
    public init<T>(_ value: T) where T : BinaryFloatingPoint

    /// Creates an XPCLiteralValue from a Bool.
    public init(_ value: Bool)

    /// Creates an XPCLiteralValue from an XPCDictionary.
    public init(_ value: XPCDictionary)
}
extension

XPCLiteralValue

NewiOSmacOStvOSwatchOS
extension XPCLiteralValue : ExpressibleByStringLiteral
Declaration
extension XPCLiteralValue : ExpressibleByStringLiteral {

    /// Creates an instance initialized to the given string value.
    ///
    /// - Parameter value: The value of the new instance.
    public init(stringLiteral value: String)

    /// A type that represents an extended grapheme cluster literal.
    ///
    /// Valid types for `ExtendedGraphemeClusterLiteralType` are `Character`,
    /// `String`, and `StaticString`.
    @available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)
    public typealias ExtendedGraphemeClusterLiteralType = String

    /// A type that represents a string literal.
    ///
    /// Valid types for `StringLiteralType` are `String` and `StaticString`.
    @available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)
    public typealias StringLiteralType = String

    /// A type that represents a Unicode scalar literal.
    ///
    /// Valid types for `UnicodeScalarLiteralType` are `Unicode.Scalar`,
    /// `Character`, `String`, and `StaticString`.
    @available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)
    public typealias UnicodeScalarLiteralType = String
}
extension

XPCLiteralValue

NewiOSmacOStvOSwatchOS
extension XPCLiteralValue : ExpressibleByIntegerLiteral
Declaration
extension XPCLiteralValue : ExpressibleByIntegerLiteral {

    /// Creates an instance initialized to the specified integer value.
    ///
    /// Do not call this initializer directly. Instead, initialize a variable or
    /// constant using an integer literal. For example:
    ///
    ///     let x = 23
    ///
    /// In this example, the assignment to the `x` constant calls this integer
    /// literal initializer behind the scenes.
    ///
    /// - Parameter value: The value to create.
    public init(integerLiteral value: Int)

    /// A type that represents an integer literal.
    ///
    /// The standard library integer and floating-point types are all valid types
    /// for `IntegerLiteralType`.
    @available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)
    public typealias IntegerLiteralType = Int
}
extension

XPCLiteralValue

NewiOSmacOStvOSwatchOS
extension XPCLiteralValue : ExpressibleByBooleanLiteral
Declaration
extension XPCLiteralValue : ExpressibleByBooleanLiteral {

    /// Creates an instance initialized to the given Boolean value.
    ///
    /// Do not call this initializer directly. Instead, initialize a variable or
    /// constant using one of the Boolean literals `true` and `false`. For
    /// example:
    ///
    ///     let twasBrillig = true
    ///
    /// In this example, the assignment to the `twasBrillig` constant calls this
    /// Boolean literal initializer behind the scenes.
    ///
    /// - Parameter value: The value of the new instance.
    public init(booleanLiteral value: Bool)

    /// A type that represents a Boolean literal, such as `Bool`.
    @available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)
    public typealias BooleanLiteralType = Bool
}
extension

XPCLiteralValue

NewiOSmacOStvOSwatchOS
extension XPCLiteralValue : ExpressibleByFloatLiteral
Declaration
extension XPCLiteralValue : ExpressibleByFloatLiteral {

    /// Creates an instance initialized to the specified floating-point value.
    ///
    /// Do not call this initializer directly. Instead, initialize a variable or
    /// constant using a floating-point literal. For example:
    ///
    ///     let x = 21.5
    ///
    /// In this example, the assignment to the `x` constant calls this
    /// floating-point literal initializer behind the scenes.
    ///
    /// - Parameter value: The value to create.
    public init(floatLiteral value: Double)

    /// A type that represents a floating-point literal.
    ///
    /// Valid types for `FloatLiteralType` are `Float`, `Double`, and `Float80`
    /// where available.
    @available(macOS 27.0, iOS 27.0, tvOS 27.0, watchOS 27.0, *)
    public typealias FloatLiteralType = Double
}
subscript

XPCDictionary.subscript

NewiOSmacOStvOSwatchOS
public subscript(key: String, as type: XPCArray.Type = XPCArray.self, default defaultValue: @autoclosure () -> XPCArray) -> XPCArray { get }

Get a value in this dictionary as an XPCArray.

Parameters

key
The key under which to get the XPCArray.
type
The expected type of the resulting value.
defaultValue
The value to produce if no XPCArray is available under key.

ReturnsAn XPCArray value, possibly defaultValue.

typealias

XPCLiteralValue.BooleanLiteralType

NewiOSmacOStvOSwatchOS
public typealias BooleanLiteralType = Bool

A type that represents a Boolean literal, such as Bool.

typealias

XPCLiteralValue.ExtendedGraphemeClusterLiteralType

NewiOSmacOStvOSwatchOS
public typealias ExtendedGraphemeClusterLiteralType = String

A type that represents an extended grapheme cluster literal.

Valid types for ExtendedGraphemeClusterLiteralType are Character, String, and StaticString.

typealias

XPCLiteralValue.FloatLiteralType

NewiOSmacOStvOSwatchOS
public typealias FloatLiteralType = Double

A type that represents a floating-point literal.

Valid types for FloatLiteralType are Float, Double, and Float80 where available.

typealias

XPCLiteralValue.IntegerLiteralType

NewiOSmacOStvOSwatchOS
public typealias IntegerLiteralType = Int

A type that represents an integer literal.

The standard library integer and floating-point types are all valid types for IntegerLiteralType.

typealias

XPCLiteralValue.StringLiteralType

NewiOSmacOStvOSwatchOS
public typealias StringLiteralType = String

A type that represents a string literal.

Valid types for StringLiteralType are String and StaticString.

typealias

XPCLiteralValue.UnicodeScalarLiteralType

NewiOSmacOStvOSwatchOS
public typealias UnicodeScalarLiteralType = String

A type that represents a Unicode scalar literal.

Valid types for UnicodeScalarLiteralType are Unicode.Scalar, Character, String, and StaticString.

No APIs match your filter.

← More in Storage, System & Virtualization