github/gitignore · Swift.gitignore

Swift .gitignore テンプレート解説

Swift.gitignore が xcuserdata、アプリのパッケージングファイル、Swift Package Manager の .build、Carthage のビルド、fastlane の成果物を無視する理由と、CocoaPods・Package.resolved の判断基準を説明します。

ジェネレーターで開く macOS, Xcode, Objective-C と一緒に開く

Swift.gitignore は Xcode で iOS・macOS アプリを作るプロジェクトや、Swift Package Manager でパッケージを開発するプロジェクトを対象とする。Xcode のユーザー固有の状態と配布ファイル、依存関係管理ツール(SwiftPM・Carthage・CocoaPods)のビルド結果、fastlane のレポートを扱う。

テンプレートにはコメントアウトされた選択式のルールが多い。Pods/Packages/Package.resolved*.xcworkspace のように、チームの方針によってコミットするかどうかが分かれる項目は既定では無視せず、判断に委ねている。

ルール別の解説

パターン何を、なぜ無視するか
xcuserdata/ユーザー固有の Xcode 状態スキームの選択、ブレークポイント、ウィンドウ配置など開発者ごとに異なる設定が、.xcodeproj.xcworkspace 内の xcuserdata に保存される。共有すると互いの設定を上書きし続けることになる。
*.hmapヘッダーマップXcode がビルド中に作るヘッダー検索用のファイルである。
*.ipa*.dSYM.zip*.dSYMアプリのパッケージング配布用のアプリアーカイブと、クラッシュ解析用のシンボルファイルである。ビルドのたびに新しく作られ、容量が大きい。dSYM はクラッシュレポートサービスにアップロードして保管する。
timeline.xctimelineplayground.xcworkspacePlaygroundSwift Playground が実行時に作るタイムラインと内部ワークスペースである。
.build/Swift Package Managerswift build が依存関係のチェックアウトとコンパイル結果を入れるフォルダーである。いつでも再作成される。
Carthage/Build/CarthageCarthage がビルドしたフレームワークである。ソースのチェックアウト(Carthage/Checkouts)はコメントとしてのみ残し、選択できるようにしている。
fastlane/report.xmlfastlane/Preview.htmlfastlane/screenshots/**/*.pngfastlane/test_outputfastlanefastlane の実行レポートとスクリーンショットである。テンプレートのコメントのとおり、スクリーンショットは必要なときに再生成することが推奨される。

実務での注意点

元のテンプレート

Swift.gitignoreルール 13 行
# 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

テンプレートの出典: github/gitignore/Swift.gitignore @356fd7b (2026-09-11) · CC0-1.0

一緒に使うテンプレート

ほかのテンプレートの解説