home / skills / nonameplum / agent-skills / swift-package-manager

swift-package-manager skill

/swift-package-manager

This skill helps you navigate Swift Package Manager documentation to create, manage, and build Swift packages efficiently.

npx playbooks add skill nonameplum/agent-skills --skill swift-package-manager

Review the files below or copy the command above to add this skill to your agents.

Files (88)
SKILL.md
4.4 KB
---
name: swift-package-manager
description: Swift Package Manager documentation - create packages, manage dependencies, build and test Swift code
---

# PackageManagerDocs

Organize, manage, and edit Swift packages.

## Documentation Structure

### Essentials

- **Getting Started** ([GettingStarted.md](GettingStarted.md)): Learn to create and use Swift packages.
- **Introducing Packages** ([IntroducingPackages.md](IntroducingPackages.md)): Learn to create and use a Swift package.
- **Package Security** ([PackageSecurity.md](PackageSecurity.md)): Learn about the security features that the package manager implements.

### Guides

- **Creating a Swift package** ([CreatingSwiftPackage.md](CreatingSwiftPackage.md)): Bundle executable or shareable code into a standalone Swift package.
- **Setting the Swift tools version** ([SettingSwiftToolsVersion.md](SettingSwiftToolsVersion.md)): Define the minimum version of the swift compiler required for your package.
- **Adding dependencies to a Swift package** ([AddingDependencies.md](AddingDependencies.md)): Use other Swift packages, system libraries, or binary dependencies in your package.
- **Resolving and updating dependencies** ([ResolvingPackageVersions.md](ResolvingPackageVersions.md)): Coordinate and constrain dependencies for your package.
- **Creating C language targets** ([CreatingCLanguageTargets.md](CreatingCLanguageTargets.md)): Include C language code as a target in your Swift package.
- **Using build configurations** ([UsingBuildConfigurations.md](UsingBuildConfigurations.md)): Control the build configuration for your app or package.
- **Packaging based on the version of Swift** ([SwiftVersionSpecificPackaging.md](SwiftVersionSpecificPackaging.md)): Provide a package manifest for a specific version of Swift.
- **Bundling resources with a Swift package** ([BundlingResources.md](BundlingResources.md)): Add resource files to your Swift package and access them in your code.
- **Releasing and publishing a Swift package** ([ReleasingPublishingAPackage.md](ReleasingPublishingAPackage.md)): Share a specific version of your package.
- **Continuous Integration Workflows** ([ContinuousIntegration.md](ContinuousIntegration.md)): Build Swift packages with an existing continuous integration setup and prepare apps that consume package dependencies within an existing CI pipeline.
- **Plugins** ([Plugins.md](Plugins.md)): Extend package manager functionality with build or command plugins.
- **Module Aliasing** ([ModuleAliasing.md](ModuleAliasing.md)): Create aliased names for modules to avoid collisions between targets in your package or its dependencies.
- **Using a package registry** ([UsingSwiftPackageRegistry.md](UsingSwiftPackageRegistry.md)): Configure and use a package registry for Swift Package Manager.
- **Package Collections** ([PackageCollections.md](PackageCollections.md)): Learn to create, publish and use Swift package collections.
- **Using shell completion scripts** ([UsingShellCompletion.md](UsingShellCompletion.md)): Customize your shell to automatically complete swift package commands.
- **Swift Package Manager as a library** ([SwiftPMAsALibrary.md](SwiftPMAsALibrary.md)): Include Swift Package Manager as a dependency in your Swift package.

### Swift Commands

- **swift build** ([SwiftBuild.md](SwiftBuild.md)): Build sources into binary products.
- **swift test** ([SwiftTest.md](SwiftTest.md)): Build and run tests.
- **swift package** ([SwiftPackageCommands.md](SwiftPackageCommands.md)): Subcommands to update and inspect your Swift package.
- **swift sdk** ([SwiftSDKCommands.md](SwiftSDKCommands.md)): Perform operations on Swift SDKs.
- **swift package-registry** ([SwiftPackageRegistryCommands.md](SwiftPackageRegistryCommands.md)): Interact with package registry and manage related configuration.
- **swift package-collection** ([SwiftPackageCollectionCommands.md](SwiftPackageCollectionCommands.md)): Interact with package collections.
- **swift run** ([SwiftRun.md](SwiftRun.md)): Build and run an executable product.

### Design

- **Swift Package Registry Service Specification** ([RegistryServerSpecification.md](RegistryServerSpecification.md)): Learn about the specification for SwiftPM's registry service.

## Usage Notes

- Documentation is organized progressively from getting started to advanced topics
- Start with the Introduction or Getting Started section
- Consult specific guides for detailed information

## License & Attribution

This skill contains content converted from DocC documentation format.

Overview

This skill documents Swift Package Manager (SwiftPM) features for creating packages, managing dependencies, building, and testing Swift code. It guides you from initial package setup through advanced topics like plugins, package registries, and CI integration. The content is organized for progressive learning so you can quickly move from getting started to publishing and maintaining packages.

How this skill works

The documentation explains how to create Swift packages, define manifests, add and resolve dependencies, and produce binary or executable products. It describes command-line workflows (swift build, swift test, swift run, swift package, and registry/collection commands) and covers build configuration, resource bundling, and interoperability with C or binary targets. Advanced sections cover plugins, package collections, registry usage, and embedding SwiftPM as a library in other tools.

When to use it

  • Starting a new Swift library or executable to share or reuse code.
  • Adding or updating third-party dependencies in a Swift project.
  • Packaging resources or C/binary targets alongside Swift code.
  • Setting up CI pipelines to build and test Swift packages automatically.
  • Publishing a versioned package to a registry or package collection.
  • Customizing build behavior with plugins or module aliasing to avoid name collisions.

Best practices

  • Start with the Getting Started and Introducing Packages guides to establish a correct manifest and project layout.
  • Pin dependency versions and use semantic version constraints to avoid unexpected updates.
  • Include resources and platform constraints in the Package manifest to ensure reproducible builds.
  • Use CI workflows to validate builds and tests across supported Swift versions and platforms.
  • Document and test plugin behavior and binary targets carefully to ensure reproducible integration for consumers.
  • Prefer package collections or a registry for discoverability and consistent dependency resolution across teams.

Example use cases

  • Create a cross-platform Swift library and publish a versioned release to a package registry.
  • Add a third-party networking package with constrained version requirements and ensure tests pass in CI.
  • Bundle images and localization files with a package and access them from code using resource APIs.
  • Integrate a C library target for performance-sensitive code and expose Swift wrappers.
  • Write a build plugin to perform code generation at build time for multiple packages.
  • Assemble a package collection for an organization to simplify dependency onboarding.

FAQ

Where should I start if I'm new to Swift packages?

Begin with the Getting Started or Introducing Packages guides to learn package layout, manifest syntax, and basic commands like swift build and swift test.

How do I publish a package for others to use?

Prepare a versioned release, ensure your manifest and resources are correct, then publish to a package registry or host the repository with tags so consumers can add it as a dependency.