<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "macCatalyst: 17.4.0 -",
    "macOS: 14.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.1.0 -",
    "watchOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/xpc_connection_set_peer_entitlement_exists_requirement(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "c:@F@xpc_connection_set_peer_entitlement_exists_requirement"
  },
  "title" : "xpc_connection_set_peer_entitlement_exists_requirement(_:_:)"
}
-->

# xpc_connection_set_peer_entitlement_exists_requirement(_:_:)

Sets a requirement that the executable for the peer process has a valid code signature that contains an entitlement.

```
func xpc_connection_set_peer_entitlement_exists_requirement(_ connection: xpc_connection_t, _ entitlement: UnsafePointer<CChar>) -> Int32
```

## Parameters

`connection`

The XPC connection.

`entitlement`

The name of the entitlement to check.

## Return Value

On success, `0`. Otherwise, a value from [Errors](/documentation/XPC/xpc-connections#Errors).

## Discussion

When you set this requirement on a connection, the operating system checks that peer process satisfies the requirement every time it sends a message to your process. If the peer process initiated the connection and its executable doesn’t have the requested entitlement, then you don’t receive a message and the operating system doesn’t call your event handler. If your process sent a message to its peer expecting a reply, and its executable doesn’t have the requested entitlement, then you don’t receive a reply and the operating system delivers [`XPC_ERROR_PEER_CODE_SIGNING_REQUIREMENT`](/documentation/XPC/XPC_ERROR_PEER_CODE_SIGNING_REQUIREMENT-c.macro) instead.

> Important:
> It’s an error to call this function multiple times for the same connection, or to call multiple functions that set code-signing requirements on the same connection. If you do, then the operating system terminates your process.

---

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)