<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "XPC",
  "identifier" : "/documentation/XPC/XPCSession/setPeerRequirement(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "XPC"
    ],
    "preciseIdentifier" : "s:3XPC10XPCSessionC18setPeerRequirementyyAA07XPCPeerE0VF"
  },
  "title" : "setPeerRequirement(_:)"
}
-->

# setPeerRequirement(_:)

Requires that the session peer has the specified requirement

```
func setPeerRequirement(_ requirement: XPCPeerRequirement)
```

## Discussion

- requirement: The requirement the peer must have

> Note: The session must be inactive to set a peer requirement. It is a
> programming error to call multiple of the `setPeerRequirement` method
> on the same session.

> Note: All messages received on this session will be checked to
> ensure that they come from a peer who satisfies the requirement. When
> a reply is expected on the session and the peer does not satisfy the
> requirement, the session will be canceled and user’s cancelation
> handler will be invoked with `XPCRichError` describing the code
> signing error.

---

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)