Swift .gitignore Template Explained
Why Swift.gitignore ignores xcuserdata, app packaging files, Swift Package Manager's .build, Carthage builds and fastlane output, and how to decide on CocoaPods and Package.resolved.
Swift.gitignore targets projects that build iOS or macOS apps with Xcode or develop packages with Swift Package Manager. It covers Xcode per-user state and distribution files, build output from dependency managers (SwiftPM, Carthage, CocoaPods) and fastlane reports.
The template has many optional rules that are commented out. Items whose commit status depends on team policy, such as Pods/, Packages/, Package.resolved and *.xcworkspace, are not ignored by default and are left to your judgment.
Rules explained
| Pattern | What it ignores and why |
|---|---|
xcuserdata/ | Per-user Xcode stateSettings that differ per developer, such as the selected scheme, breakpoints and window layout, are stored in xcuserdata inside .xcodeproj and .xcworkspace. If shared, people keep overwriting each other's settings. |
*.hmap | Header mapsFiles Xcode creates during builds for header lookup. |
*.ipa*.dSYM.zip*.dSYM | App packagingDistribution app archives and symbol files for crash analysis. They are recreated on every build and are large. Upload dSYMs to your crash reporting service to keep them. |
timeline.xctimelineplayground.xcworkspace | PlaygroundThe timeline and internal workspace that a Swift Playground creates as it runs. |
.build/ | Swift Package ManagerThe folder where swift build puts dependency checkouts and compilation results. It can be recreated at any time. |
Carthage/Build/ | CarthageFrameworks built by Carthage. The source checkouts (Carthage/Checkouts) are left only as a comment so you can choose. |
fastlane/report.xmlfastlane/Preview.htmlfastlane/screenshots/**/*.pngfastlane/test_output | fastlanefastlane run reports and screenshots. As the template comments say, it is recommended to regenerate screenshots when needed. |
Practical notes
- The template's default is not to ignore CocoaPods'
Pods/. Committing it lets you build withoutpod installbut makes the repository larger. Either way, commitPodfile.lock. - For apps, it is common to commit
Package.resolvedso everyone builds with the same dependency versions. - Since you work on macOS, also select the macOS template (or the Xcode template) to block
.DS_Store.
Original template
# Xcode## gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore## User settingsxcuserdata/## Obj-C/Swift specific*.hmap## App packaging*.ipa*.dSYM.zip*.dSYM## Playgroundstimeline.xctimelineplayground.xcworkspace# Swift Package Manager## Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.# Packages/# Package.pins# Package.resolved# *.xcodeproj## Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata# hence it is not needed unless you have added a package configuration file to your project# .swiftpm.build/# CocoaPods## We recommend against adding the Pods directory to your .gitignore. However# you should judge for yourself, the pros and cons are mentioned at:# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control## Pods/## Add this line if you want to avoid checking in source code from the Xcode workspace# *.xcworkspace# Carthage## Add this line if you want to avoid checking in source code from Carthage dependencies.# Carthage/CheckoutsCarthage/Build/# fastlane## It is recommended to not store the screenshots in the git repo.# Instead, use fastlane to re-generate the screenshots whenever they are needed.# For more information about the recommended setup visit:# https://docs.fastlane.tools/best-practices/source-control/#source-controlfastlane/report.xmlfastlane/Preview.htmlfastlane/screenshots/**/*.pngfastlane/test_output
Templates from github/gitignore/Swift.gitignore @356fd7b (2026-09-11) · CC0-1.0