This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Build the package
swift build
# Run tests
swift test
# Run a single test
swift test --filter SFSymbolsProviderTests.SourceScannerTests/testScanSimple
# Build and run the example app
cd Example && swift buildSFSymbolsProvider is an SPM Build Tool Plugin that provides an SF Symbols-like API for third-party icon libraries (Phosphor Icons and Ionicons). The system works by scanning source code at build time and generating only the icons that are actually used.
Runtime Library (Sources/SFSymbolsProvider/):
Image+Extensions.swift- SwiftUIImage(icon:)initializer that loads icons from asset catalogs. Handles bundle discovery across platforms (UIKit/AppKit differences).SourceScanner.swift- Regex-based scanner that extractsImage(icon: "ph.*")andImage(icon: "ion.*")calls from Swift source files. Also containsIconNameparser for decomposing icon strings into provider/name/weight/variant.
Build Tool (Sources/SFSymbolsProviderTool/):
main.swift- CLI with three commands:build(combined scan+generate),scan(extract icons to manifest),generate(create xcassets from manifest). Handles platform detection and callsactoolfor asset compilation.AssetGenerator.swift- Maps icon names to SVG file paths, generates Contents.json for imagesets with template rendering.
SPM Plugin (Plugins/SFSymbolsProviderPlugin/):
Plugin.swift- BuildToolPlugin that wires the CLI tool into SPM builds. Passes source directories and bundled resources to the tool.
- Plugin invokes
SFSymbolsProviderTool build --source <target-sources> --output <plugin-work-dir> --resources <bundled-icons> SourceScanner.scanDirectory()finds allImage(icon: "...")calls via regexAssetGenerator.validateIcons()checks which icons have corresponding SVG source files- Tool generates
.xcassetswith one.imagesetper icon, configured for template rendering - Tool compiles xcassets to
.bundleusingxcrun actool - At runtime,
Image(icon:)looks up the asset by name from the compiled bundle
- Phosphor:
ph.{name}[.{weight}]where weight is thin/light/regular/bold/fill - Ionicons:
ion.{name}[.{variant}]where variant is outline/sharp
- macOS builds with
swift buildwork out of the box - iOS/watchOS/tvOS Xcode projects need a Run Script phase to copy plugin outputs (SPM limitation)
- The tool auto-detects platform from
PLATFORM_NAMEandSDK_NAMEenvironment variables