|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides guidance to AI agents 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 | + |
| 78 | +-------------------------------------------------------------------------------- |
| 79 | +## Documentation |
| 80 | + |
| 81 | +Use swift-docc format when writing documentation. |
| 82 | + |
| 83 | +Follow SwiftUI documentation style. |
| 84 | + |
| 85 | +Since CDDefaultCodeListingLanguage is Swift, stop using ```swift and ``` to wrap Swift code example in documentation. Instead just use a new line + 4 space indent. |
| 86 | + |
| 87 | +Example: |
| 88 | + |
| 89 | +``` |
| 90 | + /// Example code: |
| 91 | + /// |
| 92 | + /// @main |
| 93 | + /// struct MyApp: App { |
| 94 | + /// var body: some View { |
| 95 | + /// WindowGroup { |
| 96 | + /// ContentView() |
| 97 | + /// } |
| 98 | + /// .environment(ProfileService.currentProfile) |
| 99 | + /// } |
| 100 | + /// } |
| 101 | + /// |
| 102 | + public protocol App {} |
| 103 | +``` |
0 commit comments