<!--
{
  "documentType" : "article",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/xpc-objects",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "XPC objects"
}
-->

# XPC objects

Encapsulate data in objects that represent primitive types, collections, and more.

## Topics

### Objects

[`xpc_object_t`](/documentation/XPC/xpc_object_t)

A type that can describe all XPC objects, including dictionaries, arrays, strings, and numbers.

[`xpc_type_t`](/documentation/XPC/xpc_type_t)

A type that describes XPC object types.

[`OS_xpc_object`](/documentation/XPC/OS_xpc_object)

The interface for an XPC object.

[`OS_xpc_listener`](/documentation/XPC/OS_xpc_listener-swift.class)

[`OS_xpc_listener`](/documentation/XPC/OS_xpc_listener-c.protocol)

### Identity

[`xpc_get_type`](/documentation/XPC/xpc_get_type(_:))

Returns the type of an object.

[`xpc_type_get_name`](/documentation/XPC/xpc_type_get_name(_:))

Returns a string that describes an XPC object type.

[`xpc_hash`](/documentation/XPC/xpc_hash(_:))

Calculates a hash value for the specified object.

### Comparison

[`xpc_equal`](/documentation/XPC/xpc_equal(_:_:))

Compares two objects for equality.

### Copying

[`xpc_copy`](/documentation/XPC/xpc_copy(_:))

Creates a copy of the object.

[`xpc_copy_description`](/documentation/XPC/xpc_copy_description(_:))

Copies a debug string that describes the object.

### Boolean objects

[`xpc_bool_create`](/documentation/XPC/xpc_bool_create(_:))

Creates an XPC Boolean object.

[`xpc_bool_get_value`](/documentation/XPC/xpc_bool_get_value(_:))

Returns the underlying Boolean value from the object.

[`XPC_BOOL_TRUE`](/documentation/XPC/XPC_BOOL_TRUE-swift.var)

A constant that represents a Boolean value of true.

[`XPC_BOOL_FALSE`](/documentation/XPC/XPC_BOOL_FALSE-swift.var)

A constant that represents a Boolean value of false.

[`XPC_BOOL_TRUE`](/documentation/XPC/XPC_BOOL_TRUE-c.macro)

A constant that represents a Boolean value of true.

[`XPC_BOOL_FALSE`](/documentation/XPC/XPC_BOOL_FALSE-c.macro)

A constant that represents a Boolean value of false.

### Data objects

[`xpc_data_create`](/documentation/XPC/xpc_data_create(_:_:))

Creates an XPC object that represents a buffer of bytes.

[`xpc_data_create_with_dispatch_data`](/documentation/XPC/xpc_data_create_with_dispatch_data(_:))

Creates an XPC object that represents a buffer of bytes that the specified GCD data object describes.

[`xpc_data_get_bytes`](/documentation/XPC/xpc_data_get_bytes(_:_:_:_:))

Copies the bytes in a data object into the specified buffer.

[`xpc_data_get_bytes_ptr`](/documentation/XPC/xpc_data_get_bytes_ptr(_:))

Returns a pointer to the internal storage of a data object.

[`xpc_data_get_length`](/documentation/XPC/xpc_data_get_length(_:))

Returns the length of the data that an XPC data object encapsulates.

### Number objects

[`xpc_double_create`](/documentation/XPC/xpc_double_create(_:))

Creates an XPC double object.

[`xpc_double_get_value`](/documentation/XPC/xpc_double_get_value(_:))

Returns the underlying double-precision floating point value from an object.

[`xpc_int64_create`](/documentation/XPC/xpc_int64_create(_:))

Creates an XPC signed integer object.

[`xpc_int64_get_value`](/documentation/XPC/xpc_int64_get_value(_:))

Returns the underlying signed 64-bit integer value from an object.

[`xpc_uint64_create`](/documentation/XPC/xpc_uint64_create(_:))

Creates an XPC unsigned integer object.

[`xpc_uint64_get_value`](/documentation/XPC/xpc_uint64_get_value(_:))

Returns the underlying unsigned 64-bit integer value from an object.

### Array objects

[`XPCArray`](/documentation/XPC/XPCArray)

An ordered random-access collection of XPC objects.

[`xpc_array_create`](/documentation/XPC/xpc_array_create(_:_:))

Creates an XPC object that represents an array of XPC objects.

[`xpc_array_create_empty`](/documentation/XPC/xpc_array_create_empty())

Creates an XPC object that represents an array of XPC objects.

[`xpc_array_create_connection`](/documentation/XPC/xpc_array_create_connection(_:_:))

Creates a connection object from an array directly.

[`xpc_array_set_value`](/documentation/XPC/xpc_array_set_value(_:_:_:))

Inserts the specified object into the array at the specified index.

[`xpc_array_get_value`](/documentation/XPC/xpc_array_get_value(_:_:))

Returns the value at the specified index in the array.

[`xpc_array_append_value`](/documentation/XPC/xpc_array_append_value(_:_:))

Appends an object to an XPC array.

[`xpc_array_get_count`](/documentation/XPC/xpc_array_get_count(_:))

Returns the count of values in the array.

[`xpc_array_apply`](/documentation/XPC/xpc_array_apply(_:_:))

Invokes the specified block for every value in the array.

[`xpc_array_dup_fd`](/documentation/XPC/xpc_array_dup_fd(_:_:))

Gets a file descriptor from an array directly.

[`xpc_array_get_array`](/documentation/XPC/xpc_array_get_array(_:_:))

Returns the array at the specified index in the array.

[`xpc_array_get_bool`](/documentation/XPC/xpc_array_get_bool(_:_:))

Gets a Boolean primitive value from an array directly.

[`xpc_array_get_data`](/documentation/XPC/xpc_array_get_data(_:_:_:))

Gets a pointer to the raw bytes of a data object from an array directly.

[`xpc_array_get_date`](/documentation/XPC/xpc_array_get_date(_:_:))

Gets a date interval from an array directly.

[`xpc_array_get_dictionary`](/documentation/XPC/xpc_array_get_dictionary(_:_:))

Returns the dictionary at the specified index in the array.

[`xpc_array_get_double`](/documentation/XPC/xpc_array_get_double(_:_:))

Gets a double-precision floating point primitive value from an array directly.

[`xpc_array_get_int64`](/documentation/XPC/xpc_array_get_int64(_:_:))

Gets a 64-bit integer primitive value from an array directly.

[`xpc_array_get_string`](/documentation/XPC/xpc_array_get_string(_:_:))

Gets a C-string value from an array directly.

[`xpc_array_get_uint64`](/documentation/XPC/xpc_array_get_uint64(_:_:))

Gets a 64-bit unsigned integer primitive value from an array directly.

[`xpc_array_get_uuid`](/documentation/XPC/xpc_array_get_uuid(_:_:))

Gets a UUID value from an array directly.

[`xpc_array_set_bool`](/documentation/XPC/xpc_array_set_bool(_:_:_:))

Inserts a Boolean primitive value into an array.

[`xpc_array_set_connection`](/documentation/XPC/xpc_array_set_connection(_:_:_:))

Inserts a connection into an array.

[`xpc_array_set_data`](/documentation/XPC/xpc_array_set_data(_:_:_:_:))

Inserts a raw data value into an array.

[`xpc_array_set_date`](/documentation/XPC/xpc_array_set_date(_:_:_:))

Inserts a date value into an array.

[`xpc_array_set_double`](/documentation/XPC/xpc_array_set_double(_:_:_:))

Inserts a double-precision floating point primitive value into an array.

[`xpc_array_set_fd`](/documentation/XPC/xpc_array_set_fd(_:_:_:))

Inserts a file descriptor into an array.

[`xpc_array_set_int64`](/documentation/XPC/xpc_array_set_int64(_:_:_:))

Inserts a 64-bit integer primitive value into an array.

[`xpc_array_set_string`](/documentation/XPC/xpc_array_set_string(_:_:_:))

Inserts a C-string into an array.

[`xpc_array_set_uint64`](/documentation/XPC/xpc_array_set_uint64(_:_:_:))

Inserts a 64-bit unsigned integer primitive value into an array.

[`xpc_array_set_uuid`](/documentation/XPC/xpc_array_set_uuid(_:_:_:))

Inserts a UUID primitive value into an array.

[`xpc_array_applier_t`](/documentation/XPC/xpc_array_applier_t)

A block to invoke for every value in the array.

[`XPC_ARRAY_APPEND`](/documentation/XPC/XPC_ARRAY_APPEND-swift.var)

A constant to pass as the destination index to the class of primitive XPC array setters indicating that the specified primitive needs to append to the array.

[`XPC_ARRAY_APPEND`](/documentation/XPC/XPC_ARRAY_APPEND-c.macro)

A constant to pass as the destination index to the class of primitive XPC array setters indicating that the specified primitive needs to append to the array.

### Dictionary objects

[`XPCDictionary`](/documentation/XPC/XPCDictionary)

A type that contains key-value pairs, notably used as the container of messages between a client and listener.

[`xpc_dictionary_create`](/documentation/XPC/xpc_dictionary_create(_:_:_:))

Creates an XPC object that represents a dictionary of XPC objects keyed to C-strings.

[`xpc_dictionary_create_empty`](/documentation/XPC/xpc_dictionary_create_empty())

Creates an XPC object that represents a dictionary of XPC objects keyed to C-strings.

[`xpc_dictionary_create_connection`](/documentation/XPC/xpc_dictionary_create_connection(_:_:))

Creates a connection from a dictionary directly.

[`xpc_dictionary_create_reply`](/documentation/XPC/xpc_dictionary_create_reply(_:))

Creates a dictionary that is in reply to the specified dictionary.

[`xpc_dictionary_set_value`](/documentation/XPC/xpc_dictionary_set_value(_:_:_:))

Sets the value for the specified key to the specified object.

[`xpc_dictionary_get_count`](/documentation/XPC/xpc_dictionary_get_count(_:))

Returns the number of values in the dictionary.

[`xpc_dictionary_get_value`](/documentation/XPC/xpc_dictionary_get_value(_:_:))

Returns the value for the specified key.

[`xpc_dictionary_apply`](/documentation/XPC/xpc_dictionary_apply(_:_:))

Invokes the specified block for every key-value pair in the dictionary.

[`xpc_dictionary_dup_fd`](/documentation/XPC/xpc_dictionary_dup_fd(_:_:))

Creates a file descriptor from a dictionary directly.

[`xpc_dictionary_get_array`](/documentation/XPC/xpc_dictionary_get_array(_:_:))

Returns the array value for the specified key.

[`xpc_dictionary_get_bool`](/documentation/XPC/xpc_dictionary_get_bool(_:_:))

Gets a Boolean primitive value from a dictionary directly.

[`xpc_dictionary_get_data`](/documentation/XPC/xpc_dictionary_get_data(_:_:_:))

Gets a raw data value from a dictionary directly.

[`xpc_dictionary_get_date`](/documentation/XPC/xpc_dictionary_get_date(_:_:))

Gets a date value from a dictionary directly.

[`xpc_dictionary_get_dictionary`](/documentation/XPC/xpc_dictionary_get_dictionary(_:_:))

Returns the dictionary value for the specified key.

[`xpc_dictionary_get_double`](/documentation/XPC/xpc_dictionary_get_double(_:_:))

Gets a double-precision floating point primitive value from a dictionary directly.

[`xpc_dictionary_get_int64`](/documentation/XPC/xpc_dictionary_get_int64(_:_:))

Gets a 64-bit integer primitive value from a dictionary directly.

[`xpc_dictionary_get_remote_connection`](/documentation/XPC/xpc_dictionary_get_remote_connection(_:))

Returns the connection that receives the dictionary.

[`xpc_dictionary_get_string`](/documentation/XPC/xpc_dictionary_get_string(_:_:))

Gets a C-string value from a dictionary directly.

[`xpc_dictionary_get_uint64`](/documentation/XPC/xpc_dictionary_get_uint64(_:_:))

Gets a 64-bit unsigned integer primitive value from a dictionary directly.

[`xpc_dictionary_get_uuid`](/documentation/XPC/xpc_dictionary_get_uuid(_:_:))

Gets a UUID value from a dictionary directly.

[`xpc_dictionary_set_bool`](/documentation/XPC/xpc_dictionary_set_bool(_:_:_:))

Inserts a Boolean primitive value into a dictionary.

[`xpc_dictionary_set_connection`](/documentation/XPC/xpc_dictionary_set_connection(_:_:_:))

Inserts a connection into a dictionary.

[`xpc_dictionary_set_data`](/documentation/XPC/xpc_dictionary_set_data(_:_:_:_:))

Inserts a raw data value into a dictionary.

[`xpc_dictionary_set_date`](/documentation/XPC/xpc_dictionary_set_date(_:_:_:))

Inserts a date primitive value into a dictionary.

[`xpc_dictionary_set_double`](/documentation/XPC/xpc_dictionary_set_double(_:_:_:))

Inserts a double-precision floating point primitive value into a dictionary.

[`xpc_dictionary_set_fd`](/documentation/XPC/xpc_dictionary_set_fd(_:_:_:))

Inserts a file descriptor into a dictionary.

[`xpc_dictionary_set_int64`](/documentation/XPC/xpc_dictionary_set_int64(_:_:_:))

Inserts a 64-bit integer primitive value into a dictionary.

[`xpc_dictionary_set_string`](/documentation/XPC/xpc_dictionary_set_string(_:_:_:))

Inserts a C-string value into a dictionary.

[`xpc_dictionary_set_uint64`](/documentation/XPC/xpc_dictionary_set_uint64(_:_:_:))

Inserts a 64-bit unsigned integer primitive value into a dictionary.

[`xpc_dictionary_set_uuid`](/documentation/XPC/xpc_dictionary_set_uuid(_:_:_:))

Inserts a UUID primitive value into an array.

[`xpc_dictionary_applier_t`](/documentation/XPC/xpc_dictionary_applier_t)

A block to invoke for every key-value pair in the dictionary.

[`xpc_dictionary_copy_mach_send`](/documentation/XPC/xpc_dictionary_copy_mach_send(_:_:))

[`xpc_dictionary_set_mach_send`](/documentation/XPC/xpc_dictionary_set_mach_send(_:_:_:))

### String objects

[`xpc_string_create`](/documentation/XPC/xpc_string_create(_:))

Creates an XPC object that represents a null-terminated C-string.

[`xpc_string_create_with_format`](/documentation/XPC/xpc_string_create_with_format)

Creates an XPC object that represents a C-string that the specified format string and arguments generate.

[`xpc_string_create_with_format_and_arguments`](/documentation/XPC/xpc_string_create_with_format_and_arguments(_:_:))

Creates an XPC object that represents a C-string that the specified format string and argument list pointer generate.

[`xpc_string_get_length`](/documentation/XPC/xpc_string_get_length(_:))

Returns the length of the underlying string.

[`xpc_string_get_string_ptr`](/documentation/XPC/xpc_string_get_string_ptr(_:))

Returns a pointer to the internal storage of a string object.

### File Descriptor objects

[`xpc_fd_create`](/documentation/XPC/xpc_fd_create(_:))

Creates an XPC object that represents a POSIX file descriptor.

[`xpc_fd_dup`](/documentation/XPC/xpc_fd_dup(_:))

Returns a file descriptor that is equivalent to the one that the specified file descriptor object boxes.

### Date objects

[`xpc_date_create`](/documentation/XPC/xpc_date_create(_:))

Creates an XPC date object.

[`xpc_date_create_from_current`](/documentation/XPC/xpc_date_create_from_current())

Creates an XPC date object that represents the current date.

[`xpc_date_get_value`](/documentation/XPC/xpc_date_get_value(_:))

Returns the underlying date interval from an object.

### UUID objects

[`xpc_uuid_create`](/documentation/XPC/xpc_uuid_create(_:))

Creates an XPC object that represents a universally unique identifier (UUID).

[`xpc_uuid_get_bytes`](/documentation/XPC/xpc_uuid_get_bytes(_:))

Copies the UUID that an XPC UUID object boxes into the specified UUID buffer.

### Shared memory objects

[`xpc_shmem_create`](/documentation/XPC/xpc_shmem_create(_:_:))

Creates an XPC object that represents the specified shared memory region.

[`xpc_shmem_map`](/documentation/XPC/xpc_shmem_map(_:_:))

Maps the region that the XPC shared memory object boxes into the caller’s address space.

### Null objects

[`xpc_null_create`](/documentation/XPC/xpc_null_create())

Creates an XPC object that represents the null object.

### Object life cycle

[`xpc_retain`](/documentation/XPC/xpc_retain)

Increments the reference count of an object.

[`xpc_release`](/documentation/XPC/xpc_release)

Decrements the reference count of an object.

[`xpc_retain(_:)`](/documentation/XPC/xpc_retain(_:))

[`xpc_release(_:)`](/documentation/XPC/xpc_release(_:))

### Types of objects

[`XPC_TYPE_ACTIVITY`](/documentation/XPC/XPC_TYPE_ACTIVITY-swift.var)

A type that represents the XPC activity object.

[`XPC_TYPE_ARRAY`](/documentation/XPC/XPC_TYPE_ARRAY-swift.var)

A type that represents an array of XPC objects.

[`XPC_TYPE_BOOL`](/documentation/XPC/XPC_TYPE_BOOL-swift.var)

A type that represents a Boolean value.

[`XPC_TYPE_CONNECTION`](/documentation/XPC/XPC_TYPE_CONNECTION-swift.var)

A type that represents a connection to a named service.

[`XPC_TYPE_DATA`](/documentation/XPC/XPC_TYPE_DATA-swift.var)

A type that represents an arbitrary buffer of bytes.

[`XPC_TYPE_DATE`](/documentation/XPC/XPC_TYPE_DATE-swift.var)

A type that represents a date interval.

[`XPC_TYPE_DICTIONARY`](/documentation/XPC/XPC_TYPE_DICTIONARY-swift.var)

A type that represents a dictionary of XPC objects keyed off of C-strings.

[`XPC_TYPE_DOUBLE`](/documentation/XPC/XPC_TYPE_DOUBLE-swift.var)

A type that represents an IEEE-compliant, double-precision floating point value.

[`XPC_TYPE_ENDPOINT`](/documentation/XPC/XPC_TYPE_ENDPOINT-swift.var)

A type that represents a connection in serialized form.

[`XPC_TYPE_FD`](/documentation/XPC/XPC_TYPE_FD-swift.var)

A type that represents a POSIX file descriptor.

[`XPC_TYPE_INT64`](/documentation/XPC/XPC_TYPE_INT64-swift.var)

A type that represents a signed, 64-bit integer value.

[`XPC_TYPE_NULL`](/documentation/XPC/XPC_TYPE_NULL-swift.var)

A type that represents a null object.

[`XPC_TYPE_SHMEM`](/documentation/XPC/XPC_TYPE_SHMEM-swift.var)

A type that represents a region of shared memory.

[`XPC_TYPE_STRING`](/documentation/XPC/XPC_TYPE_STRING-swift.var)

A type that represents a null-terminated C-string.

[`XPC_TYPE_UINT64`](/documentation/XPC/XPC_TYPE_UINT64-swift.var)

A type that represents an unsigned, 64-bit integer value.

[`XPC_TYPE_UUID`](/documentation/XPC/XPC_TYPE_UUID-swift.var)

A type that represents a universally unique identifier.

[`XPC_TYPE_ACTIVITY`](/documentation/XPC/XPC_TYPE_ACTIVITY-c.macro)

A type that represents the XPC activity object.

[`XPC_TYPE_ARRAY`](/documentation/XPC/XPC_TYPE_ARRAY-c.macro)

A type that represents an array of XPC objects.

[`XPC_TYPE_BOOL`](/documentation/XPC/XPC_TYPE_BOOL-c.macro)

A type that represents a Boolean value.

[`XPC_TYPE_CONNECTION`](/documentation/XPC/XPC_TYPE_CONNECTION-c.macro)

A type that represents a connection to a named service.

[`XPC_TYPE_DATA`](/documentation/XPC/XPC_TYPE_DATA-c.macro)

A type that represents an arbitrary buffer of bytes.

[`XPC_TYPE_DATE`](/documentation/XPC/XPC_TYPE_DATE-c.macro)

A type that represents a date interval.

[`XPC_TYPE_DICTIONARY`](/documentation/XPC/XPC_TYPE_DICTIONARY-c.macro)

A type that represents a dictionary of XPC objects keyed off of C-strings.

[`XPC_TYPE_DOUBLE`](/documentation/XPC/XPC_TYPE_DOUBLE-c.macro)

A type that represents an IEEE-compliant, double-precision floating point value.

[`XPC_TYPE_ENDPOINT`](/documentation/XPC/XPC_TYPE_ENDPOINT-c.macro)

A type that represents a connection in serialized form.

[`XPC_TYPE_FD`](/documentation/XPC/XPC_TYPE_FD-c.macro)

A type that represents a POSIX file descriptor.

[`XPC_TYPE_INT64`](/documentation/XPC/XPC_TYPE_INT64-c.macro)

A type that represents a signed, 64-bit integer value.

[`XPC_TYPE_NULL`](/documentation/XPC/XPC_TYPE_NULL-c.macro)

A type that represents a null object.

[`XPC_TYPE_SHMEM`](/documentation/XPC/XPC_TYPE_SHMEM-c.macro)

A type that represents a region of shared memory.

[`XPC_TYPE_STRING`](/documentation/XPC/XPC_TYPE_STRING-c.macro)

A type that represents a null-terminated C-string.

[`XPC_TYPE_UINT64`](/documentation/XPC/XPC_TYPE_UINT64-c.macro)

A type that represents an unsigned, 64-bit integer value.

[`XPC_TYPE_UUID`](/documentation/XPC/XPC_TYPE_UUID-c.macro)

A type that represents a universally unique identifier.

### Errors

[`XPCRichError`](/documentation/XPC/XPCRichError)

An error that contains a description and indicates if you can retry the operation that caused the error.

[`XPC_TYPE_RICH_ERROR`](/documentation/XPC/XPC_TYPE_RICH_ERROR-swift.var)

A type that represents a rich error object.

[`XPC_TYPE_ERROR`](/documentation/XPC/XPC_TYPE_ERROR-swift.var)

A type that represents an error object.

[`XPC_ERROR_KEY_DESCRIPTION`](/documentation/XPC/XPC_ERROR_KEY_DESCRIPTION-swift.var)

A key for querying an error dictionary to retrieve a string with a human-readable description of the error.

[`XPC_TYPE_ERROR`](/documentation/XPC/XPC_TYPE_ERROR-c.macro)

A type that represents an error object.

[`XPC_ERROR_KEY_DESCRIPTION`](/documentation/XPC/XPC_ERROR_KEY_DESCRIPTION-c.macro)

A key for querying an error dictionary to retrieve a string with a human-readable description of the error.

[`XPC_ERROR_PEER_CODE_SIGNING_REQUIREMENT`](/documentation/XPC/XPC_ERROR_PEER_CODE_SIGNING_REQUIREMENT-swift.var)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)