<!--
{
  "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/LaunchCodeRequirement",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "LightweightCodeRequirements"
    ],
    "preciseIdentifier" : "s:27LightweightCodeRequirements06LaunchB11RequirementV"
  },
  "title" : "LaunchCodeRequirement"
}
-->

# LaunchCodeRequirement

A lightweight code requirement that you use to evaluate the executable for a launching process.

```
struct LaunchCodeRequirement
```

## Overview

If you set a `LaunchCodeRequirement` object for a launching process and the executable doesn’t satisfy the requirement,
the operating system doesn’t run the process and creates a crash report instead.
[`LaunchCodeRequirement`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement) objects can only be built using constraints that conform to the [`LaunchConstraint`](/documentation/LightweightCodeRequirements/LaunchConstraint) protocol.
Note that [`LaunchCodeRequirement`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement) are applied to processes. If a launch requests execution of ‘#!’ script, the launch constraint
will be applied to the interpreter. For example a script with the following ‘#!’ will apply a launch constraint to bash.

```bash
#! /bin/bash
```

if the ‘#!’ is instead:

```bash
 #! /usr/bin/env python
```

Then the launch constraint is applied to env.

## Topics

### Initializers

[`init(ProcessCodeRequirement) throws`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement/init(_:)-5fh0u)

Convert a [`ProcessCodeRequirement`](/documentation/LightweightCodeRequirements/ProcessCodeRequirement) to a [`LaunchCodeRequirement`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement) if possible.

[`init(OnDiskCodeRequirement) throws`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement/init(_:)-6hixy)

Convert a [`OnDiskCodeRequirement`](/documentation/LightweightCodeRequirements/OnDiskCodeRequirement) to a [`LaunchCodeRequirement`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement) if possible.

[`init(from: any Decoder) throws`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement/init(from:))

Create a new instance by decoding from the given decoder

### Instance Methods

[`func encode(to: any Encoder) throws`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement/encode(to:))

Encodes this value into the given encoder

### Type Methods

[`static func allOf(requirement: () -> [any LaunchConstraint]) throws -> LaunchCodeRequirement`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement/allOf(requirement:))

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

[`static func anyOf(requirement: () -> [any LaunchConstraint]) throws -> LaunchCodeRequirement`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement/anyOf(requirement:))

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

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Encodable`](/documentation/Swift/Encodable)

[`Equatable`](/documentation/Swift/Equatable)

[`Decodable`](/documentation/Swift/Decodable)

[`Sendable`](/documentation/Swift/Sendable)

---

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)