github/gitignore · Swift.gitignore

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.

Open in generator Open with macOS, Xcode, Objective-C

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

PatternWhat 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.
*.hmapHeader mapsFiles Xcode creates during builds for header lookup.
*.ipa*.dSYM.zip*.dSYMApp 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.xcworkspacePlaygroundThe 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_outputfastlanefastlane run reports and screenshots. As the template comments say, it is recommended to regenerate screenshots when needed.

Practical notes

Original template

Swift.gitignore13 rules
# 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

Often used together

More template explanations