---
title: "setCodeSigningRequirement(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsxpcconnection/setcodesigningrequirement(_:)"
---

# setCodeSigningRequirement(_:)

Sets the code signing requirement for this connection.

## Declaration

```swift
func setCodeSigningRequirement(_ requirement: String)
```

## Parameters

- `requirement`: A string that describes requirements expected of the connection peer. See https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/ for more information on the code signing format.

## Discussion

Discussion Use this method to enforce a code-signing requirement on the peer process of an XPC connection. The following example shows how a client can ensure that the XPC service on the other end of a connection has a specific entitlement. Calling this method with a malformed requirement results in a fatal error in Swift, or throws an exception in Objective-C. If new messages don’t match the requirement, the connection becomes invalidated. Call this method before calling resume(), since it’s an XPC error to call this method more than once.
