# madsmtm/objc2 architecture

> Architecture diagram of the GitHub repository madsmtm/objc2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/madsmtm/objc2
- Repository: https://github.com/madsmtm/objc2

## Overview

This workspace provides Rust interoperability with Objective-C: the core `objc2` crate models Objective-C objects and runtime operations, while framework crates expose Apple APIs in Rust. A typical user writes Rust code against those bindings; `objc2` performs typed message sending and object-management operations through the Objective-C runtime, and framework calls reach Apple frameworks. `block2` and `dispatch2` provide callback and concurrency APIs. The tree and README establish these product areas, but sampled source is limited, so detailed call wiring is shown only where supported.

Main entry points: [`crates/objc2/src/lib.rs`](https://github.com/madsmtm/objc2/blob/main/crates/objc2/src/lib.rs) (objc2 API), [`framework-crates/objc2-app-kit/src/lib.rs`](https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-app-kit/src/lib.rs) (Framework bindings), [`framework-crates/objc2-app-kit/src/application.rs`](https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-app-kit/src/application.rs) (AppKit APIs), [`framework-crates/objc2-ui-kit/src/application.rs`](https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-ui-kit/src/application.rs) (UIKit APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interop["Objective-C interop"]
  node_objc2["objc2 API<br/>[lib.rs]"]
  node_macros["Interop macros<br/>[mod.rs]"]
  node_runtime_ffi["Runtime FFI<br/>[mod.rs]"]
  node_encoding["Type encoding<br/>[lib.rs]"]
  node_ownership["Object ownership<br/>[mod.rs]"]
end

subgraph group_support["Interop support"]
  node_blocks["Objective-C blocks<br/>[lib.rs]"]
  node_dispatch["Dispatch APIs<br/>[lib.rs]"]
end

subgraph group_frameworks["Apple bindings"]
  node_framework_bindings["Framework bindings<br/>[lib.rs]"]
  node_appkit["AppKit APIs<br/>[application.rs]"]
  node_uikit["UIKit APIs<br/>[application.rs]"]
  node_core_audio["Core Audio Kit<br/>[view_controller.rs]"]
  node_core_graphics["Core Graphics<br/>[pdf_context.rs]"]
end

subgraph group_platform["Apple platform"]
  node_objc_runtime{{"Objective-C runtime"}}
  node_apple_frameworks{{"Apple frameworks"}}
end

node_rust_app(("Rust application"))

node_rust_app -->|"uses APIs"| node_objc2
node_rust_app -->|"uses bindings"| node_framework_bindings
node_objc2 -->|"exposes macros"| node_macros
node_objc2 -->|"invokes FFI"| node_runtime_ffi
node_objc2 -->|"manages objects"| node_ownership
node_objc2 -->|"encodes types"| node_encoding
node_objc2 -->|"sends messages"| node_objc_runtime
node_framework_bindings -->|"uses interop"| node_objc2
node_framework_bindings -->|"includes APIs"| node_appkit
node_framework_bindings -->|"includes APIs"| node_uikit
node_framework_bindings -->|"includes APIs"| node_core_audio
node_framework_bindings -->|"includes APIs"| node_core_graphics
node_appkit -->|"calls APIs"| node_apple_frameworks
node_uikit -->|"starts app"| node_apple_frameworks
node_core_audio -->|"binds APIs"| node_apple_frameworks
node_core_graphics -->|"binds APIs"| node_apple_frameworks
node_rust_app -->|"uses callbacks"| node_blocks
node_rust_app -->|"uses concurrency"| node_dispatch

click node_objc2 "https://github.com/madsmtm/objc2/blob/main/crates/objc2/src/lib.rs"
click node_macros "https://github.com/madsmtm/objc2/blob/main/crates/objc2/src/__macros/mod.rs"
click node_runtime_ffi "https://github.com/madsmtm/objc2/blob/main/crates/objc2/src/ffi/mod.rs"
click node_encoding "https://github.com/madsmtm/objc2/blob/main/crates/objc2-encode/src/lib.rs"
click node_ownership "https://github.com/madsmtm/objc2/blob/main/crates/objc2/src/rc/mod.rs"
click node_blocks "https://github.com/madsmtm/objc2/blob/main/crates/block2/src/lib.rs"
click node_dispatch "https://github.com/madsmtm/objc2/blob/main/crates/dispatch2/src/lib.rs"
click node_framework_bindings "https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-app-kit/src/lib.rs"
click node_appkit "https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-app-kit/src/application.rs"
click node_uikit "https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-ui-kit/src/application.rs"
click node_core_audio "https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-core-audio-kit/src/view_controller.rs"
click node_core_graphics "https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-core-graphics/src/pdf_context.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_objc2,node_macros,node_runtime_ffi,node_encoding,node_ownership toneBlue
class node_blocks,node_dispatch toneAmber
class node_framework_bindings,node_appkit,node_uikit,node_core_audio,node_core_graphics toneMint
class node_objc_runtime,node_apple_frameworks toneRose
class node_rust_app toneIndigo
```

## Components

### Objective-C interop

- [objc2 API](https://github.com/madsmtm/objc2/blob/main/crates/objc2/src/lib.rs): `crates/objc2/src/lib.rs`
- [Interop macros](https://github.com/madsmtm/objc2/blob/main/crates/objc2/src/__macros/mod.rs): `crates/objc2/src/__macros/mod.rs`
- [Runtime FFI](https://github.com/madsmtm/objc2/blob/main/crates/objc2/src/ffi/mod.rs): `crates/objc2/src/ffi/mod.rs`
- [Type encoding](https://github.com/madsmtm/objc2/blob/main/crates/objc2-encode/src/lib.rs): `crates/objc2-encode/src/lib.rs`
- [Object ownership](https://github.com/madsmtm/objc2/blob/main/crates/objc2/src/rc/mod.rs): `crates/objc2/src/rc/mod.rs`

### Interop support

- [Objective-C blocks](https://github.com/madsmtm/objc2/blob/main/crates/block2/src/lib.rs): `crates/block2/src/lib.rs`
- [Dispatch APIs](https://github.com/madsmtm/objc2/blob/main/crates/dispatch2/src/lib.rs): `crates/dispatch2/src/lib.rs`

### Apple bindings

- [Framework bindings](https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-app-kit/src/lib.rs): `framework-crates/objc2-app-kit/src/lib.rs`
- [AppKit APIs](https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-app-kit/src/application.rs): `framework-crates/objc2-app-kit/src/application.rs`
- [UIKit APIs](https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-ui-kit/src/application.rs): `framework-crates/objc2-ui-kit/src/application.rs`
- [Core Audio Kit](https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-core-audio-kit/src/view_controller.rs): `framework-crates/objc2-core-audio-kit/src/view_controller.rs`
- [Core Graphics](https://github.com/madsmtm/objc2/blob/main/framework-crates/objc2-core-graphics/src/pdf_context.rs): `framework-crates/objc2-core-graphics/src/pdf_context.rs`

### Apple platform

- **Objective-C runtime**
- **Apple frameworks**

### Other components

- **Rust application**

## Connections

- Rust application → objc2 API: uses APIs
- Rust application → Framework bindings: uses bindings
- objc2 API → Interop macros: exposes macros
- objc2 API → Runtime FFI: invokes FFI
- objc2 API → Object ownership: manages objects
- objc2 API → Type encoding: encodes types
- objc2 API → Objective-C runtime: sends messages
- Framework bindings → objc2 API: uses interop
- Framework bindings → AppKit APIs: includes APIs
- Framework bindings → UIKit APIs: includes APIs
- Framework bindings → Core Audio Kit: includes APIs
- Framework bindings → Core Graphics: includes APIs
- AppKit APIs → Apple frameworks: calls APIs
- UIKit APIs → Apple frameworks: starts app
- Core Audio Kit → Apple frameworks: binds APIs
- Core Graphics → Apple frameworks: binds APIs
- Rust application → Objective-C blocks: uses callbacks
- Rust application → Dispatch APIs: uses concurrency
