Skip to content

Commit 4f7888f

Browse files
authored
Add Claude.md (#485)
1 parent 182d1f1 commit 4f7888f

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ Example/Example.xcodeproj/xcshareddata
1717

1818
__Snapshots__
1919
Example/ReferenceImages/**/*.png
20+
21+
.claude

CLAUDE.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
OpenSwiftUI is an open source implementation of Apple's SwiftUI framework, designed to:
8+
- Build GUI apps on non-Apple platforms (Linux, Windows)
9+
- Diagnose and debug SwiftUI issues on Apple platforms
10+
- Maintain API compatibility with SwiftUI
11+
12+
This project is in active development and contains multiple Swift packages with extensive environment-based configuration.
13+
14+
## Build Commands
15+
16+
### Standard Build
17+
```bash
18+
./Scripts/build.sh
19+
# Or directly: swift build
20+
```
21+
22+
### Build with Library Evolution
23+
```bash
24+
./Scripts/build_swiftinterface.sh
25+
# Generates module interfaces for library evolution
26+
```
27+
28+
### Environment Variables
29+
The build system uses many environment variables for configuration:
30+
- `OPENSWIFTUI_BUILD_FOR_DARWIN_PLATFORM`: Build for Darwin platforms (default: true on macOS)
31+
- `OPENSWIFTUI_DEVELOPMENT`: Enable development mode features
32+
- `OPENSWIFTUI_USE_LOCAL_DEPS`: Use local dependency paths instead of remote repos
33+
- `OPENSWIFTUI_LIBRARY_EVOLUTION`: Enable library evolution support
34+
- `OPENSWIFTUI_COMPATIBILITY_TEST`: Run compatibility tests with SwiftUI
35+
36+
## Test Commands
37+
38+
### Run All Tests
39+
```bash
40+
swift test
41+
```
42+
43+
### Run Specific Test Target
44+
```bash
45+
swift test --filter OpenSwiftUICoreTests
46+
swift test --filter OpenSwiftUICompatibilityTests
47+
swift test --filter OpenSwiftUISymbolDualTests
48+
```
49+
50+
### Test with Coverage
51+
```bash
52+
swift test --enable-code-coverage
53+
```
54+
55+
### List Available Tests
56+
```bash
57+
swift test --list-tests
58+
```
59+
60+
## Dependencies Setup
61+
62+
The project requires cloning additional repositories in the same parent directory:
63+
64+
```bash
65+
cd ..
66+
git clone https://github.com/OpenSwiftUIProject/OpenAttributeGraph.git
67+
git clone https://github.com/OpenSwiftUIProject/OpenRenderBox.git
68+
git clone https://github.com/OpenSwiftUIProject/DarwinPrivateFrameworks.git
69+
```
70+
71+
## Architecture
72+
73+
### Core Modules
74+
75+
1. **OpenSwiftUI_SPI**: System Programming Interface and low-level utilities
76+
2. **OpenSwiftUICore**: Core framework implementation with animations, layout, graphics
77+
3. **OpenSwiftUI**: Main public API layer, SwiftUI-compatible interface
78+
4. **OpenSwiftUIExtension**: Additional APIs extending OpenSwiftUI/SwiftUI
79+
5. **OpenSwiftUIBridge**: Bridge layer for migrating from other frameworks
80+
81+
### Key Source Directories
82+
83+
- `Sources/OpenSwiftUICore/`: Core implementation (Animation, Layout, Graphics, etc.)
84+
- `Sources/OpenSwiftUI/`: Public API layer matching SwiftUI
85+
- `Sources/OpenSwiftUI_SPI/`: Low-level system interfaces and utilities
86+
- `Sources/COpenSwiftUI/`: C/Objective-C interop code
87+
- `Tests/`: Comprehensive test suites for all modules
88+
- `Example/`: Demo applications and UI tests
89+
90+
### Testing Framework
91+
92+
The project uses **swift-testing framework** (not XCTest):
93+
- Import with `import Testing`
94+
- Use `@Test` attribute for test functions
95+
- Use `#expect()` for assertions instead of XCTest assertions
96+
- No comments in test case bodies - keep tests clean and self-explanatory
97+
98+
### Code Style (from .github/copilot-instructions.md)
99+
100+
- Use `package` access level for cross-module APIs
101+
- 4-space indentation, trim trailing whitespaces
102+
- Use `// MARK: -` to separate code sections
103+
- Maximum line length: 120 characters (soft limit)
104+
- Follow SwiftUI API compatibility patterns
105+
- Prefix internal types with `_` when mirroring SwiftUI internals
106+
107+
### Platform Support
108+
109+
- **Darwin Platforms**: Currently only iOS and macOS are supported
110+
- **Linux**: Build and test support, some features limited
111+
- **Windows**: Not yet supported
112+
113+
### Development Configurations
114+
115+
For the Example app:
116+
- `SwiftUIDebug`: Run with Apple's SwiftUI
117+
- `OpenSwiftUIDebug`: Run with OpenSwiftUI implementation
118+
119+
## Environment Configuration
120+
121+
The Package.swift heavily uses environment variables for conditional compilation:
122+
- Most features are platform-dependent (Darwin vs non-Darwin)
123+
- Development mode enables additional debugging features
124+
- Library evolution mode generates .swiftinterface files
125+
- Various private framework integrations can be toggled
126+
127+
## Important Notes
128+
129+
- This project uses private Apple APIs and frameworks - NOT for App Store distribution
130+
- SwiftUI compatibility is the primary goal - match Apple's API signatures exactly
131+
- The project requires Swift 6.1.2+ and specific platform versions
132+
- Cross-platform support relies on custom implementations of Apple frameworks

0 commit comments

Comments
 (0)