---
title: "setPeerRequirement(_:)"
framework: xpc
role: symbol
role_heading: Instance Method
path: "xpc/xpcsession/setpeerrequirement(_:)"
---

# setPeerRequirement(_:)

Requires that the session peer has the specified requirement

## Declaration

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

## Discussion

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.
