226
votes

What should the typical .gitignore include for Xcode 6?

Also for information regarding the xccheckout introduced in Xcode 5 see here

3
This isn't a "primarily opinion-based" question. There are files that git should always ignore in XCode, program files such as xcuserdata. The choice to exclude these is in no way opinion based. - Dermot
I second Dermot on that one! Not ignoring some files causes errors, therefore there is a definitive best practice. Half of the code examples shared in SO answers could be equally considered opinions as there are other ways of doing things, but there are generally accepted best practices and de facto standards. - rage
Maybe closed partly because there's an extensive answer here: stackoverflow.com/questions/49478/… . In my research, you are incorrect to say that .xccheckout should be ignored - but it's not 100% clear, and I've logged a bug with Apple asking for an official answer. - Adam

3 Answers

276
votes

1)

The easiest answer is that mine looks like this:

# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
# Pods - for those of you who use CocoaPods
Pods

which I believe is the same .gitignore that GitHub sets up with all their repositories by default.

2)

Another answer is that there's a website called "gitignore.io" , which generates the files based on the .gitignore templates from https://github.com/github/gitignore.

58
votes

If you are creating a new project from scratch in Xcode 6 ... there is no need for a long .gitignore file anymore, as I pointed out in my last post: Apple optimized the standard project file and folder structure to meet the requirements for clear and straight forward git commits. Apple also ignores two file patterns by default if you create the git repository with a Xcode project template:

.DS_Store
UserInterfaceState.xcuserstate

They added them to your .git/info/excludes file in your project directory. So no need to re-ignore them in .gitignore :-)

The only thing I always include in a .gitignore file is the

# Exclude personal Xcode user settings
xcuserdata/ 
6
votes

Refer to Github's Xcode.gitignore file to always have an updated listing of which Xcode files to ignore.