This Claude skill provides comprehensive expertise in Swift Package Manager (SPM), the native tool for managing the distribution of Swift code. It empowers developers to master dependency management, modularize codebases through local packages, and configure complex Package.swift manifests. By covering everything from basic library creation to advanced Swift Macros and CLI automation, this skill streamlines the development workflow for iOS, macOS, and server-side Swift projects.
Use Cases
Architecting modular applications by breaking down monolithic codebases into reusable local Swift packages to improve build times and maintainability.
Configuring complex Package.swift files with multiple targets, conditional platform dependencies, and custom build settings for cross-platform support.
Migrating legacy projects from third-party dependency managers like CocoaPods or Carthage to a native Swift Package Manager workflow.
Developing and distributing open-source Swift libraries with proper semantic versioning and automated testing configurations.
Troubleshooting dependency resolution conflicts and optimizing CI/CD pipelines using SPM command-line tools for automated building and testing.
name
swift-spm
description
Master Swift Package Manager - dependencies, creating libraries, publishing, local packages
version
"2.0.0"
sasmp_version
"1.3.0"
bonded_agent
01-swift-fundamentals
bond_type
SECONDARY_BOND
Swift Package Manager Skill
Dependency management, package creation, and distribution with Swift Package Manager.
// In your app's Package.swift or Xcode project
// Use local path during development
// Package.swift with local override
let package = Package(
name: "MyApp",
dependencies: [
// Production: Use remote
// .package(url: "https://github.com/company/SharedKit", from: "1.0.0")
// Development: Use local
.package(path: "../SharedKit")
],
targets: [
.target(name: "MyApp", dependencies: ["SharedKit"])
]
)
# Create new package
swift package init --type library
swift package init --type executable
swift package init --type macro
# Build
swift build
swift build -c release
# Test
swift test
swift test --filter MyTests
# Update dependencies
swift package update
swift package update PackageName
# Resolve dependencies
swift package resolve
# Show dependencies
swift package show-dependencies
swift package show-dependencies --format json
# Generate Xcode project (deprecated but useful)
swift package generate-xcodeproj
# Clean
swift package clean
swift package reset
# Dump package description
swift package dump-package
Troubleshooting
Common Issues
Issue
Cause
Solution
"No such module"
Missing dependency
Add to target dependencies
Version conflict
Incompatible requirements
Use version that satisfies all
Build fails on CI
Different Swift version
Pin swift-tools-version
Resources not found
Wrong resource rule
Use .process or .copy correctly
Xcode not seeing changes
Cache stale
Clean derived data
Debug Tips
# Verbose build
swift build -v
# Check resolved versions
cat Package.resolved
# Dependency tree
swift package show-dependencies --format dot | dot -Tpng -o deps.png
# Rebuild from scratch
rm -rf .build Package.resolved
swift package resolve
swift build
Validation Rules
validation:
- rule: pin_versions
severity: warning
check: Use version ranges, not branch/revision in production
- rule: semantic_versioning
severity: error
check: Follow semver for your packages
- rule: platform_support
severity: info
check: Declare minimum platform versions