Swift Package Configuration
Relevant source files
The following files were used as context for generating this wiki page:
The Swift Package Configuration defines the build structure and environment for the kilde project, a macOS tool for recording screen and system audio. It uses Swift Package Manager (SPM) to manage dependencies, platforms, and target executables.
The configuration currently supports macOS v14 and later, focusing on a primary executable target named spike. This target serves as a verification tool for screen capture, audio loopback, and permission handling.
Sources: Package.swift:4-15, README.md:1-12
Package Structure and Targets
The project is structured as a single Swift package named kilde. It contains one executable target that encapsulates the experimental logic for the recording system.
| Component | Type | Path | Description |
|---|---|---|---|
kilde | Package | / | The root package name. |
spike | Executable Target | Sources/Spike | A tool used to verify design specifications and core recording features. |
Sources: Package.swift:4-15, Sources/Spike/main.swift:1-41
Target Architecture
The spike target functions as a command-line interface (CLI). It initializes as an accessory application to ensure it has the necessary access to the WindowServer for ScreenCaptureKit operations.
The diagram shows the relationship between the package definition and the internal CLI structure of the spike tool.
Sources: Package.swift:8-13, Sources/Spike/main.swift:6-10
Build Environment Requirements
The package requires specific Swift and macOS versions to utilize modern frameworks like ScreenCaptureKit and AVFoundation.
- Swift Tools Version: 5.10
- Platform: macOS v14
- Permissions: Requires Screen Recording and Microphone permissions, which are verified via the
doctorcommand.
Sources: Package.swift:1-6, Sources/Spike/Doctor.swift:7-15
Command Implementation Logic
The spike executable parses command-line arguments to execute specific recording or diagnostic tasks. The main.swift file acts as the entry point, routing execution to specialized command structures.
Execution Flow
When a user runs a command, the tool follows a structured path from argument parsing to resource cleanup.
This diagram illustrates the lifecycle of a command execution within the spike target, including signal handling for safe termination.
Sources: Sources/Spike/main.swift:12-41, Sources/Spike/Util.swift:67-78
Integration and Automated Testing
The repository includes shell scripts that interact with the Swift Package Configuration to build and verify the software. The scripts/integration-test.sh script automates the build process using swift build and executes a suite of tests against the compiled spike binary.
Test Scenarios
The integration script verifies several package functionalities:
- Build Success: Ensures the package compiles without errors.
- T1 Doctor: Validates environment and permission diagnostics.
- T3/T4 Recording: Verifies system audio and microphone track separation.
- T9 Loopback: Tests integration with external audio drivers like BlackHole.
Sources: scripts/integration-test.sh:58-71, scripts/integration-test.sh:91-135
Summary
The Package.swift configuration establishes kilde as a macOS-specific project targeting recent OS versions. By defining the spike executable, it provides a centralized target for developing and testing complex media capture workflows. The configuration integrates tightly with utility modules and shell scripts to maintain a reliable development and testing environment.