public
Last active — forked from adamgit/.gitignore

  • Download Gist
.gitignore
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
#########################
# https://gist.github.com/foundry/4383910
# .gitignore file for Xcode4 / OS X Source projects
# Forked and adapted from https://gist.github.com/adamgit/3786883
# updated 2 June 2013 to include adamgit's latest version
# added notes on testing and adapting existing projects
#########################
# https://gist.github.com/adamgit/3786883
# Version 2.1
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
# - added line-by-line explanations for EVERYTHING (some were missing)
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
#########################
#
# Version 2.1
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
# - added line-by-line explanations for EVERYTHING (some were missing)
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
#########################
 
#####
# OS X temporary files that should never be committed
#
# c.f. http://www.westwind.com/reference/os-x/invisibles.html
 
.DS_Store
 
# c.f. http://www.westwind.com/reference/os-x/invisibles.html
 
.Trashes
 
# c.f. http://www.westwind.com/reference/os-x/invisibles.html
 
*.swp
 
# *.lock - this is used and abused by many editors for many different things.
# For the main ones I use (e.g. Eclipse), it should be excluded
# from source-control, but YMMV
 
*.lock
 
#
# profile - REMOVED temporarily (on double-checking, this seems incorrect; I can't find it in OS X docs?)
#profile
 
 
####
# Xcode temporary files that should never be committed
#
# NB: NIB/XIB files still exist even on Storyboard projects, so we want this...
 
*~.nib
 
 
####
# Xcode build files -
#
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "DerivedData"
 
DerivedData/
 
# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named "build"
 
build/
 
 
#####
# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups)
#
# This is complicated:
#
# SOMETIMES you need to put this file in version control.
# Apple designed it poorly - if you use "custom executables", they are
# saved in this file.
# 99% of projects do NOT use those, so they do NOT want to version control this file.
# ..but if you're in the 1%, comment out the line "*.pbxuser"
 
# .pbxuser: http://lists.apple.com/archives/xcode-users/2004/Jan/msg00193.html
 
*.pbxuser
 
# .mode1v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html
 
*.mode1v3
 
# .mode2v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html
 
*.mode2v3
 
# .perspectivev3: http://stackoverflow.com/questions/5223297/xcode-projects-what-is-a-perspectivev3-file
 
*.perspectivev3
 
# NB: also, whitelist the default ones, some projects need to use these
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
 
 
###
# the following section, whilst informative, does not work
# as you don't seem to be able to re-include (!xcshareddata !xcschemes)
# from already-excluded directories (xcuserdata)
# cf http://stackoverflow.com/questions/13732165/gitignore-negations-ignored-by-git-for-osx-xcode-project
 
 
# #### this is Adam's latest explanation (untested), but see my version (tested) below
# # Xcode 4 - semi-personal settings
# #
# #
# # OPTION 1: ---------------------------------
# # throw away ALL personal settings (including custom schemes!
# # - unless they are "shared")
# #
# # NB: this is exclusive with OPTION 2 below
# xcuserdata
#
# # OPTION 2: ---------------------------------
# # get rid of ALL personal settings, but KEEP SOME OF THEM
# # - NB: you must manually uncomment the bits you want to keep
# #
# # NB: this is exclusive with OPTION 1 above
# #
# #xcuserdata/**/*
#
# # (requires option 2 above): Personal Schemes
# #
# #!xcuserdata/**/xcschemes/*
 
#
#
# ####
# # XCode 4 workspaces - more detailed
# #
# # Workspaces are important! They are a core feature of Xcode - don't exclude them :)
# #
# # Workspace layout is quite spammy. For reference:
# #
# # (root)/
# # (project-name).xcodeproj/
# # project.pbxproj <-- this file is causing problems/getting corrupted
# # project.xcworkspace/
# # contents.xcworkspacedata
# # xcshareddata/ <-if included, should be under source control (shared data)
# # xcuserdata/ <-should NOT be under source control (personal data)
# # (your name).xcuserdatad/
# # UserInterfaceState.xcuserstate <-we don't want this
# # WorkspaceSettings.xcsettings <-we don't want this
# # xcuserdata/
# # (your name).xcuserdatad/
# # xcdebugger/ <-we don't want this
# # Breakpoints.xcbkptlist <-we don't want this
# # xcschemes/ <-keep??
# # (project-name).xcscheme <-keep????
# # xcschememanagement.plist <-keep????
# # xcdebugger/ <-we don't want this
# # xcschemes/ <-keep????
# #
# #
# #
# # Xcode 4 workspaces - SHARED
# #
# # This is UNDOCUMENTED (google: "developer.apple.com xcshareddata" - 0 results
# # But if you're going to kill personal workspaces, at least keep the shared ones...
# #
# #
# !xcshareddata
#
#
# ####
# # XCode 4 build-schemes
# #
# # PRIVATE ones are stored inside xcuserdata
# !xcschemes
 
 
# so instead we have to
# - optionally ignore project.xcworkspace
# - specify precisely which (other) files in xcuserdata we wish to ignore
# (there may be others, I lack the knowledge!)
# http://stackoverflow.com/questions/10956312/project-xcworkspace-is-this-important
# "project.xcworkspace ! is this important?"
# (conclusion - only important if coordinating shared workspaces between groups)
 
# OPTION 1 - exclude everything in project.xcworkspace (including shared workspaces)
# project.xcworkspace
 
# OPTION 2 - keep shared workspaces, remove user workspaces and states
project.xcworkspace/xcuserdata/
 
# if project.xcworkspace is not ignored, you will want to ignore this file
# (this should be excluded with project.xcworkspace/xcuserdata/ but I have
# not tested without this line so I am leaving it here)
 
UserInterfaceState.xcuserstate
 
 
# and in either case this
 
xcdebugger/
 
 
####
# Xcode 4 - Deprecated classes
#
# Allegedly, if you manually "deprecate" your classes, they get moved here.
#
# We're using source-control, so this is a "feature" that we do not want!
 
*.moved-aside
 
 
####
# UNKNOWN: recommended by others, but I can't discover what these files are
#
# ...none. Everything is now explained.
 
###########################
# TEST PROJECT - no gitignore
# create mode 100644 git test.xcodeproj/project.pbxproj
# create mode 100644 git test.xcodeproj/project.xcworkspace/contents.xcworkspacedata
# create mode 100644 git test.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate
# create mode 100644 git test.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
# create mode 100644 git test.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/git test custom scheme.xcscheme
# create mode 100644 git test.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist
 
# TEST PROJECT - with this gitignore
# create mode 100644 git test.xcodeproj/project.pbxproj
# create mode 100644 git test.xcodeproj/project.xcworkspace/contents.xcworkspacedata
# create mode 100644 git test.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/git test custom scheme.xcscheme
# create mode 100644 git test.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist
 
###########################
# FIXING an existing XCODE repo
# _WHILE THE PROJECT IS CLOSED_...
# fix your gitignore file to exclude things you don't want to track in future
# then
# git rm --cached on each of the files in the repo that you need to remove from tracking
# single file...
# > git rm --cached ./test.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate
# all files in a directory...
# > git rm --cached ./test.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/*
# recursive directories...
# > git rm -r --cached ./test.xcodeproj/project.xcworkspace/xcuserdata/
#
# then git commit -m "cleaned repo"
#
# (this is important - XCode will ignore your new exclusions
# if you do not make a commandline commit before using XCode again)
#
# now you can use your project in XCode

I've updated original gist with what I think fixes your problems above, using the /**/ syntax

gitignore file syntax sucks. They really didn't think this through :(.

If you're feeling brave, try it out - it's a lot easier to understand and maintain, if it works (I did a quick test - seems to work, but I don't have time to test it thoroughly)

Updated to include adamgit's latest version, also added some notes on adding a .gitignore to an existing Xcode project. I have not tested adamgit's /**/ syntax, but the (less subtle) method I do use is tested.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.