|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this |
| 4 | +repository. |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +This is `rules_swift_package_manager` - a Bazel ruleset for downloading, building, and consuming |
| 9 | +Swift packages. It builds external Swift packages using rules_swift, rules_apple, and native C/C++ |
| 10 | +rulesets, making Swift package products and targets available as Bazel targets. |
| 11 | + |
| 12 | +## Common Development Commands |
| 13 | + |
| 14 | +### Building and Testing |
| 15 | + |
| 16 | +- `bazel test //...` - Run all tests in the repository |
| 17 | +- `bazel build //...` - Build all targets |
| 18 | + |
| 19 | +### Code Maintenance |
| 20 | + |
| 21 | +- `bazel run //:tidy` - Update source files from build outputs |
| 22 | +- `bazel run //:update_build_files` - Update Bazel BUILD files using Gazelle |
| 23 | +- `bazel run //:update_files` - Quick update of source files |
| 24 | +- `bazel run //:tidy_all` - Run all tidy operations across the repository |
| 25 | + |
| 26 | +### Go-specific Commands |
| 27 | + |
| 28 | +- `bazel run //:go_mod_tidy` - Tidy Go module dependencies |
| 29 | +- `bazel run //:go_get_latest` - Update Go dependencies to latest versions |
| 30 | + |
| 31 | +### Example Testing |
| 32 | + |
| 33 | +Examples have individual `do_test` scripts that can be run to test specific functionality. |
| 34 | + |
| 35 | +## Architecture |
| 36 | + |
| 37 | +### Core Components |
| 38 | + |
| 39 | +1. **swiftpkg/** - Main Swift package management logic |
| 40 | + |
| 41 | + - `defs.bzl` - Public API exports |
| 42 | + - `internal/` - Core implementation including: |
| 43 | + - Swift package repository rules (`swift_package.bzl`, `local_swift_package.bzl`) |
| 44 | + - Build file generation (`build_files.bzl`, `swiftpkg_build_files.bzl`) |
| 45 | + - Package info processing (`pkginfos.bzl`, `pkginfo_*.bzl`) |
| 46 | + - Resource handling (`resource_files.bzl`, `resource_bundle_accessor.bzl`) |
| 47 | + - `bzlmod/` - Bazel module extension for Swift dependencies |
| 48 | + |
| 49 | +2. **tools/swift_deps_index/** - Go-based tooling for Swift dependency analysis |
| 50 | + |
| 51 | + - Processes Swift package manifests and resolution data |
| 52 | + - Generates dependency indexes and metadata |
| 53 | + |
| 54 | +3. **examples/** - Comprehensive test examples for different Swift package scenarios |
| 55 | + |
| 56 | + - Each example has its own `do_test` script and demonstrates specific features |
| 57 | + |
| 58 | +4. **ci/** - Continuous integration configuration and test definitions |
| 59 | + |
| 60 | +### Key Files |
| 61 | + |
| 62 | +- `extensions.bzl` - Bazel module extensions entry point |
| 63 | +- `MODULE.bazel` - Bazel module configuration with runtime dependencies |
| 64 | +- `shared.bazelrc` - Common Bazel configuration (bzlmod enabled, Apple toolchain setup) |
| 65 | +- `BUILD.bazel` - Root build configuration with Gazelle and maintenance targets |
| 66 | + |
| 67 | +### Testing Strategy |
| 68 | + |
| 69 | +The repository uses extensive integration testing with examples covering real-world Swift package |
| 70 | +scenarios like Firebase, gRPC, Stripe, and others. Tests verify both bzlmod and workspace modes. |
| 71 | + |
| 72 | +## Important Notes |
| 73 | + |
| 74 | +- This repository uses bzlmod by default (`--enable_bzlmod` in shared.bazelrc) |
| 75 | +- Apple toolchain configuration is handled automatically via apple_support |
| 76 | +- Swift package resolution requires `Package.swift` and `Package.resolved` files |
| 77 | +- The `tidy` target is crucial for maintaining generated BUILD files and dependencies |
| 78 | + |
| 79 | +## Development Best Practices |
| 80 | + |
| 81 | +- Always use conventional commit format for git commit messages |
0 commit comments