The perfect .gitignore
for Swift
apps
Introduction
While waiting for my flight to Munich, I found myself wondering what an essential step in any new repository setup is, and the first thing that came to my mind was adding a .gitignore
file. This small yet crucial step can save you countless headaches down the road if done correctly.
As an iOS
developer, setting up your .gitignore
properly is essential, and you’re in luck. Below, you’ll find a comprehensive .gitignore
file that you can simply paste into your Git repository.
Platforms covered
This file is tailored to cover a variety of Apple platform projects, including:
The .gitignore
file
# Xcode
#
# Remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Store
.DS_Store
## User settings
xcuserdata/
**xcuserdata
## Compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## Compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
## Obj-C/Swift specific
*.hmap
## App packaging
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
#
# Uncomment the following lines 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
#
# It's recommended to not add 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/
#
# Uncomment the following line if you want to avoid checking in source code from the Xcode workspace.
# *.xcworkspace
# Carthage
#
# Uncomment the following line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build/
# Accio dependency management
Dependencies/
.accio/
# fastlane
#
# It's recommended to not store screenshots in the git repo.
# Instead, use fastlane to regenerate the screenshots whenever needed.
# For more information about the recommended setup, visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
# Code Injection
#
# After using new code Injection tools, a generated folder /iOSInjectionProject is created.
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/
By integrating this .gitignore
file into your repository from the start, you’ll ensure that unnecessary files are kept out of your version control, leading to a cleaner, more manageable project. Safe travels and happy coding!
Written by @DanielMandea