Contributing to an open-source Swift package: fork, test and open a pull request

Most Swift libraries are distributed as Swift Package Manager (SwiftPM) packages hosted on GitHub, and most accept outside contributions. The workflow is the standard GitHub fork-and-pull-request flow, plus building and testing the package with SwiftPM.
Find a package
Section titled “Find a package”Good places to look:
- Swift Package Index, which lists packages along with the platforms and Swift versions they build on
- GitHub’s Swift topic
- Awesome Swift, a curated list of Swift libraries
A package you already use is the easiest start, since you know where it falls short. Many projects label beginner-friendly issues good first issue. For anything bigger than a small fix, comment on the issue first so you don’t build something the maintainers won’t merge.
Read the contribution guidelines
Section titled “Read the contribution guidelines”Look for CONTRIBUTING.md in the repository root or .github/ folder. It usually covers code style, how to run the tests, commit message format, and whether you need to sign a contributor licence agreement. Check for a code of conduct too.
Fork, clone and branch
Section titled “Fork, clone and branch”Fork the repository on GitHub, then clone your fork and add the original as a remote called upstream so you can pull in new changes:
git clone https://github.com/<your-username>/<package>.gitcd <package>git remote add upstream https://github.com/<owner>/<package>.gitgit checkout -b fix-issue-123Use a descriptive branch name, like fix-issue-123 or add-async-api.
Build and run the tests
Section titled “Build and run the tests”You need a Swift toolchain: Xcode on macOS, or the toolchain from swift.org on Linux and Windows. From the package root:
swift buildswift testTo use Xcode, open the package folder (or run xed . in it). Xcode reads Package.swift directly, with no .xcodeproj needed, and you can run tests with Product > Test (Cmd+U).
Run the tests before you change anything so you know what passes on a clean checkout. Packages may use XCTest, the newer Swift Testing framework (import Testing), or both, and swift test runs either. If the package supports Linux, check the project’s CI configuration to see what it runs there, since Foundation APIs differ slightly between platforms.
Make the change
Section titled “Make the change”- Follow the existing code style. Many projects enforce one with SwiftLint or swift-format; if there’s a config file for either in the repo, run it.
- Add or update tests for the behaviour you changed. A bug fix with a test that fails without it is much easier to review.
- Keep commits focused and write messages that say why the change was made, not only what changed.
Open the pull request
Section titled “Open the pull request”Before pushing, bring your branch up to date with the upstream default branch (often main):
git fetch upstreamgit rebase upstream/maingit push origin fix-issue-123GitHub then shows a Compare & pull request button on your fork. Check that the base repository is the original project and the head is your branch. In the description, say what the change does, how you tested it, and which issue it addresses. Writing Fixes #123 closes that issue automatically when the PR is merged into the default branch.
Respond to review
Section titled “Respond to review”Maintainers will often ask for changes. Push new commits to the same branch and they appear on the existing PR. If the project prefers a clean history, they may ask you to squash commits or rebase again. Reviews on volunteer-run projects can take days or weeks, so a polite ping after a week or two is fine, but repeated pings aren’t.
Further reading
Section titled “Further reading”© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)