Open source implementations of Apple SDK macros.
Note: This package is currently WIP. See xtool#101
We always track one specific version of Xcode at a time. OAM macros aim to be byte-for-byte compatible with Apple's macros in the tracked version (although we're not entirely there yet).
Currently tracking: Xcode 27.0.0 (27A266a).
This package is used by xtool: OpenAppleMacrosServer is installed into the Darwin SDK that we build.
Specifically, OpenAppleMacrosServer is a drop-in replacement for Xcode.app/Contents/Developer/Platforms/*.platform/Developer/usr/bin/swift-plugin-server.
The only other caveat is that we have to replace the lib<FOO>Macros.dylib files (in *.platform/Developer/usr/lib/swift/host/plugins/) with empty lib<FOO>Macros.so files, so that swiftc registers them as macro modules. The files stay blank because we don't actually split the macros up into shared libraries. Instead we merge all of the macros into the OpenAppleMacrosServer executable, and statically link it, for maximum portability.
The easiest way to build the server yourself is by running make docker.
You can test out the server by replacing darwin.artifactbundle/OpenAppleMacrosServer with the built output/OpenAppleMacrosServer-$(arch).
There's a test suite of source snippets in ./IntegrationTests. Invoking ./IntegrationTests/run.sh will expand each snippet using 1. Apple's implementation and 2. our implementation, and check whether they're identical.
Implementation is partially complete. PRs are welcome; AI agents are quite good at adding coverage.
Legend:
- ✅ = fully supported
- 🌗 = partially supported
- ❌ = not yet supported
AppIntents also emits extra metadata via appintentsmetadataprocessor, so implementing support will require
more than just the macros.
| Macro | Status | Notes |
|---|---|---|
@AppEntity |
❌ | |
@AppEnum |
❌ | |
@AppIntent |
❌ | |
@AssistantEntity |
❌ | |
@AssistantEnum |
❌ | |
@AssistantIntent |
❌ | |
@ComputedProperty |
❌ | |
@DeferredProperty |
❌ | |
@UnionValue |
❌ |
| Macro | Status | Notes |
|---|---|---|
@Generable |
❌ | |
@Guide |
❌ | |
@SessionPropertyEntry |
❌ |
Applies to AppKit, SwiftUI, UIKit, WidgetKit
| Macro | Status | Notes |
|---|---|---|
@Preview |
🌗 | Expands to empty output |
@Previewable |
🌗 | Expands to empty output |
| Macro | Status | Notes |
|---|---|---|
@ReportableMetadata |
❌ | |
@ReportableMetadataIgnored |
❌ | |
@ReportableMetadataKey |
❌ |
| Macro | Status | Notes |
|---|---|---|
@Attribute |
❌ | |
@Index |
❌ | |
@Model |
❌ | |
@ModelActor |
❌ | |
@Query |
❌ | |
@Relationship |
❌ | |
@Transient |
❌ | |
@Unique |
❌ |
| Macro | Status | Notes |
|---|---|---|
@Animatable |
✅ | |
@AnimatableIgnored |
✅ | |
@Entry |
✅ | |
@State |
✅ |
| Macro | Status | Notes |
|---|---|---|
@Parameter |
❌ | |
@Rule |
❌ |