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

# PlatformType

A constraint that tests whether a code file or running process targets a given platform.

```
struct PlatformType
```

## Overview

For [`ProcessCodeRequirement`](/documentation/LightweightCodeRequirements/ProcessCodeRequirement) and [`LaunchCodeRequirement`](/documentation/LightweightCodeRequirements/LaunchCodeRequirement) this constraint matches the platform type of the process  as known to the kernel.
For [`OnDiskCodeRequirement`](/documentation/LightweightCodeRequirements/OnDiskCodeRequirement) this constraint matches the platforms supported in Mach-O load commands. The [`OnDiskCodeRequirement`](/documentation/LightweightCodeRequirements/OnDiskCodeRequirement) will
be matched against a SecStaticCodeRef. For this constraint to match, the SecStaticCodeRef must reference a Mach-O. If the SecStaticCodeRef references a
specific architecture of a Mach-O then this constraint will be matched against the first LC_BUILD_VERSION or LC_VERSION_MIN_*OS load command in the Mach-O.
If the SecStaticCodeRef references a file, then this constraint will match against the load commands in the architecture that is most likely to run on the platform the code
is running on.

## Topics

### Structures

[`struct Value`](/documentation/LightweightCodeRequirements/PlatformType/Value)

Supported Platform Types for a process

### Initializers

[`init(PlatformType.Value)`](/documentation/LightweightCodeRequirements/PlatformType/init(_:))

Matches if the process is running as the specified platform type or if the file supports the specified platform type.

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

Create a new instance by decoding from the given decoder

### Instance Methods

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

Encodes this value into the given encoder

### Type Aliases

[`typealias DataType`](/documentation/LightweightCodeRequirements/PlatformType/DataType)

The basic input data type of this constraint: `PlatformType.Value`..

[`typealias OutType`](/documentation/LightweightCodeRequirements/PlatformType/OutType)

The type of this constraint: [`PlatformType`](/documentation/LightweightCodeRequirements/PlatformType)

### Type Methods

[`static func `in`(PlatformType.DataType...) -> PlatformType.OutType`](/documentation/LightweightCodeRequirements/PlatformType/in(_:)-1ndmu)

Matches if the process is running as any of the specified platform types or if the file supports any of the specified platform types.

[`static func `in`([PlatformType.DataType]) -> PlatformType.OutType`](/documentation/LightweightCodeRequirements/PlatformType/in(_:)-44pc3)

Matches if the process is running as any of the specified platform types or if the file supports any of the specified platform types.

## Relationships

### Conforms To

[`LaunchConstraint`](/documentation/LightweightCodeRequirements/LaunchConstraint)

[`ProcessConstraint`](/documentation/LightweightCodeRequirements/ProcessConstraint)

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

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

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

[`OnDiskConstraint`](/documentation/LightweightCodeRequirements/OnDiskConstraint)

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

---

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)