---
title: EntitlementsQuery
framework: lightweightcoderequirements
role: symbol
role_heading: Class
path: lightweightcoderequirements/entitlementsquery
---

# EntitlementsQuery

A constraint that tests values in the entitlements dictionary associated with a process or code file.

## Declaration

```swift
class EntitlementsQuery
```

## Overview

Overview Entitlements dictionaries use strings for keys. The value of each key could be a bool, integer, string, array or another dictionary. Arrays are homogenous. Entitlements queries are a chain of operations that allow matching against arbitrarily nested values in the dictionary. Example entitlements dictionary: <dict>     <key>com.apple.application-identifier</key>     <string>com.apple.TextEdit</string>     <key>com.apple.developer.ubiquity-container-identifiers</key>     <array>         <string>com.apple.TextEdit</string>     </array>     <key>com.apple.private.hid.client.event-dispatch.internal</key>     <true/> </dict> Example query to match the first entitlement exactly EntitlementsQuery.key("com.apple.application-identifier").matchSingle(com.apple.TextEdit) Example query to match the second entitlement exactly. EntitlementsQuery.key("com.apple.developer.ubiquity-container-identifiers").elementAtIndex(0).matchSingle("com.apple.TextEdit") or to match the second entitlement less specifically EntitlementsQuery.key("com.apple.developer.ubiquity-container-identifiers").match("com.apple.TextEdit") The following query will detect the presence of the com.apple.private.hid.client.event-dispatch.internal key without checking its value. EntitlementsQuery.key("com.apple.private.hid.client.event-dispatch.internal") To match its value add a match() call to the chain. EntitlementsQuery.key("com.apple.private.hid.client.event-dispatch.internal").match(true) The following example demonstrate the keyPrefix query. EntitlementsQuery.keyPrefix("com.apple.").match(true) The keyPrefix query will match the “com.apple.application-identifier” only. Then the match query will fail because true does not match “com.apple.TextEdit”. This constraint will cause a matching failure if the process or file being matched does not include entitlements.

## Topics

### Initializers

- [init(from:)](lightweightcoderequirements/entitlementsquery/init(from:).md)

### Instance Methods

- [elementAtIndex(_:)](lightweightcoderequirements/entitlementsquery/elementatindex(_:).md)
- [encode(to:)](lightweightcoderequirements/entitlementsquery/encode(to:).md)
- [key(_:)](lightweightcoderequirements/entitlementsquery/key(_:)-swift.method.md)
- [keyPrefix(_:)](lightweightcoderequirements/entitlementsquery/keyprefix(_:)-swift.method.md)
- [match(_:)](lightweightcoderequirements/entitlementsquery/match(_:)-5cqvy.md)
- [match(_:)](lightweightcoderequirements/entitlementsquery/match(_:)-5cw98.md)
- [match(_:)](lightweightcoderequirements/entitlementsquery/match(_:)-6msza.md)
- [matchPrefix(_:)](lightweightcoderequirements/entitlementsquery/matchprefix(_:).md)
- [matchPrefixSingle(_:)](lightweightcoderequirements/entitlementsquery/matchprefixsingle(_:).md)
- [matchSingle(_:)](lightweightcoderequirements/entitlementsquery/matchsingle(_:)-49kv7.md)
- [matchSingle(_:)](lightweightcoderequirements/entitlementsquery/matchsingle(_:)-8ggh1.md)
- [matchType(_:)](lightweightcoderequirements/entitlementsquery/matchtype(_:).md)

### Type Methods

- [key(_:)](lightweightcoderequirements/entitlementsquery/key(_:)-swift.type.method.md)
- [keyPrefix(_:)](lightweightcoderequirements/entitlementsquery/keyprefix(_:)-swift.type.method.md)

### Enumerations

- [EntitlementsQuery.DataType](lightweightcoderequirements/entitlementsquery/datatype.md)

## Relationships

### Conforms To

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [LaunchConstraint](lightweightcoderequirements/launchconstraint.md)
- [OnDiskConstraint](lightweightcoderequirements/ondiskconstraint.md)
- [ProcessConstraint](lightweightcoderequirements/processconstraint.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Testing properties of executable code

- [CodeDirectoryHash](lightweightcoderequirements/codedirectoryhash.md)
- [InfoPlistHash](lightweightcoderequirements/infoplisthash.md)
- [IsInitProcess](lightweightcoderequirements/isinitprocess.md)
- [IsMainBinary](lightweightcoderequirements/ismainbinary.md)
- [IsSIPProtected](lightweightcoderequirements/issipprotected.md)
- [PlatformType](lightweightcoderequirements/platformtype.md)
- [SigningIdentifier](lightweightcoderequirements/signingidentifier.md)
- [TeamIdentifier](lightweightcoderequirements/teamidentifier.md)
- [ValidationCategory](lightweightcoderequirements/validationcategory.md)
