---
title: CodeDirectoryHash
framework: lightweightcoderequirements
role: symbol
role_heading: Structure
path: lightweightcoderequirements/codedirectoryhash
---

# CodeDirectoryHash

A constraint that matches the hash of a code directory of a code file or of a running or launching process.

## Declaration

```swift
struct CodeDirectoryHash
```

## Overview

Overview In the context of ProcessCodeRequirement and LaunchCodeRequirement this constraint matches the hash of the chosen code directory for the running process, or the process the system is launching. In the context of OnDiskCodeRequirement this constraint matches the hash of the code directory for the specified SecStaticCodeRef that best matches the current architecture. The best match is different for processes running on Intel and Apple silicon, including an Intel process running on Apple silicon with Rosetta. To reliably identify a code file using its code directory hash, use in(_:) and supply a list of the known code directory hash values.

## Topics

### Initializers

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

### Instance Methods

- [encode(to:)](lightweightcoderequirements/codedirectoryhash/encode(to:).md)

### Type Aliases

- [CodeDirectoryHash.DataType](lightweightcoderequirements/codedirectoryhash/datatype.md)
- [CodeDirectoryHash.OutType](lightweightcoderequirements/codedirectoryhash/outtype.md)

### Type Methods

- [in(_:)](lightweightcoderequirements/codedirectoryhash/in(_:)-1kiuo.md)
- [in(_:)](lightweightcoderequirements/codedirectoryhash/in(_:)-912dv.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

- [EntitlementsQuery](lightweightcoderequirements/entitlementsquery.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)
