Swift.gitignore by Github Explained

What’s inside Swift.gitignore?

Satoru Sasozaki
3 min readJan 14, 2017
https://www.atlassian.com/git/

You put a .gitignore when you create a Xcode project because you don’t want unnecessary noise to be in your commit. But you don’t know what to put in your .gitignore so just grab Swift.gitignore from Github and go without really understanding what each line in the file means. I was doing the same but wanted to understand git in a Xcode and be confident of using git with a Xcode project.

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
.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/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/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://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output

Here’s what each line means.

Build

This directory has been replaced with

~/Library/Developer/Xcode/DerivedData

DerivedData

Build or Derived Data contains the files generated when Xcode builds your project. You can always change the location of DrivedData.

*.pbxuser

*.pbxuser contains the user’s preferences for the Xcode project such as window size, file bookmarks which are all unique to each user and don’t need to be tracked. (* is a regular expression which indicates zero or more occurrences of the preceding element. It means whatever ends with .pbxuser.)

*.mode1v3

.mode1 contains things like layout information, breakpoints, and custom executables for the project.

Scott Tooker (Apple):

The .mode1 file contains layout information for the project (like window positions and sizes, including sizes of sub-views and the like). (Handling pbxuser and mode1 files in Xcode)

*.perspectivev3

It contains information you need for Xcode to look the same when you open it next time such as where is console is open, and where the Xcode screen is on your screen.

xcuserdata & xcuserstate

This directory contains things like userstate, folders opened and last file opened. Specifically UserInterfaceState.xcuserstate contains user’s layout information. You can find the related files with the following command under your project directory.

find . -name xcuserdata

If you are using a CI tool, you may run into some issues by ignoring xcuserdata. See the details here. Is it safe to ignore /xcuserdata/ with Git if using Launch Arguments?

moved-aside

This is a directory where Xcode puts deprecated files. If you create a class with the same name of another class, Xcode will move the old class into moved-aside directory.

*.hmap

Header maps (also known as “header maps”) are files Xcode uses to compile the locations of the headers used in a target. These files use the suffix .hmap. (Header-Map Build Settings)

*.ipa

An ipa file is a binary file that stores an iOS app.

*.dSYM

A dSYM file is a “debug symbols file”. It is generated when the “Strip Debug Symbols” setting is enabled in the build settings of your project. (How is a .dSYM file created?)

timeline.xctimeline

the timeline.xctimeline file describes the timeline feature displayed in the Assistant Editor. (iOS 8: Interactive Playgrounds)

Pods

For CocoaPods, you should be fine as long as you check Podfile and Podfile.lock. For the details see this post.

--

--