---
title: "xpc_connection_set_peer_lightweight_code_requirement(_:_:)"
framework: xpc
role: symbol
role_heading: Function
path: "xpc/xpc_connection_set_peer_lightweight_code_requirement(_:_:)"
---

# xpc_connection_set_peer_lightweight_code_requirement(_:_:)

Sets a requirement that the executable for the peer process has a valid code signature that matches the lightweight code requirement.

## Declaration

```swift
func xpc_connection_set_peer_lightweight_code_requirement(_ connection: xpc_connection_t, _ lwcr: xpc_object_t) -> Int32
```

## Parameters

- `connection`: The XPC connection.
- `lwcr`: The lightweight code requirement to test for the peer process’s executable. Create an object of type doc://com.apple.xpc/documentation/XPC/XPC_TYPE_DICTIONARY-swift.var that represents the requirement, using keys and values from doc://com.apple.documentation/documentation/Security/defining-launch-environment-and-library-constraints.

## Return Value

Return Value On success, 0. Otherwise, a value from Errors.

## Discussion

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 satisfy the lightweight code requirement, 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 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.

## See Also

### Remote peer information

- [xpc_connection_get_name(_:)](xpc/xpc_connection_get_name(_:).md)
- [xpc_connection_get_euid(_:)](xpc/xpc_connection_get_euid(_:).md)
- [xpc_connection_get_egid(_:)](xpc/xpc_connection_get_egid(_:).md)
- [xpc_connection_get_pid(_:)](xpc/xpc_connection_get_pid(_:).md)
- [xpc_connection_get_asid(_:)](xpc/xpc_connection_get_asid(_:).md)
- [xpc_connection_set_peer_entitlement_exists_requirement(_:_:)](xpc/xpc_connection_set_peer_entitlement_exists_requirement(_:_:).md)
- [xpc_connection_set_peer_entitlement_matches_value_requirement(_:_:_:)](xpc/xpc_connection_set_peer_entitlement_matches_value_requirement(_:_:_:).md)
- [xpc_connection_set_peer_platform_identity_requirement(_:_:)](xpc/xpc_connection_set_peer_platform_identity_requirement(_:_:).md)
- [xpc_connection_set_peer_team_identity_requirement(_:_:)](xpc/xpc_connection_set_peer_team_identity_requirement(_:_:).md)
- [xpc_connection_set_peer_code_signing_requirement(_:_:)](xpc/xpc_connection_set_peer_code_signing_requirement(_:_:).md)
