<!--
{
  "availability" : [
    "iOS: 17.4.0 -",
    "iPadOS: 17.4.0 -",
    "macCatalyst: 17.4.0 -",
    "macOS: 14.4.0 -",
    "tvOS: 17.4.0 -",
    "visionOS: 1.1.0 -",
    "watchOS: 10.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "LightweightCodeRequirements",
  "identifier" : "/documentation/LightweightCodeRequirements/OnDiskCodeRequirement/allOf(requirement:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "LightweightCodeRequirements"
    ],
    "preciseIdentifier" : "s:27LightweightCodeRequirements06OnDiskB11RequirementV5allOf11requirementACSayAA0dE10Constraint_pGyXE_tKFZ"
  },
  "title" : "allOf(requirement:)"
}
-->

# allOf(requirement:)

Create a [`OnDiskCodeRequirement`](/documentation/LightweightCodeRequirements/OnDiskCodeRequirement) that requires matching all of the provided constraints.

```
static func allOf(@OnDiskConstraintBuilder requirement: () -> [any OnDiskConstraint]) throws -> OnDiskCodeRequirement
```

## Discussion

This operation will throw ConstraintError.duplicateKeys if more than one constraint of the same type is found in the same
logical grouping. For example the following snippets will throw:

```swift
    let req1 = try OnDiskCodeRequirement.allOf {
        SigningIdentifier("com.apple.ls")
        SigningIdentifier("com.apple.ps")
    }
    let req2 = try OnDiskCodeRequirement.allOf {
           SigningIdentifier("com.apple.ls")
           anyOf {
               SigningIdentifier("com.apple.ps")
           }
    }
    let req3 = try OnDiskCodeRequirement.allOf {
        SigningIdentifier("com.apple.ls")
        allOf {
            ValidationCategory(.platform)
            SigningIdentifier("com.apple.ps")
        }
    }
```

The second requirement throws because a single constraint within anyOf provides no option and so it gets lifted to the higher logical
group. Similarly, the third requirement throws because an allOf operation nested in an allOf operation has no logical effect, so all of the
constraints in the nested operation get lifted into the higher level group.
On the other hand the following snippet will not throw:

```swift
    let req4 = try OnDiskCodeRequirement.allOf {
        anyOf {
            SigningIdentifier("com.apple.ls")
            ValidationCategory(.platform)
        }
        anyOf {
            SigningIdentifier("com.apple.ps")
            ValidationCategory(.platform)
        }
    }
```

In this requirement, both anyOf operations provide a choice, so the two groups are considered separate.

---

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)