11

I'm new to Xcode and just found out that it stores a bunch of user information and other stuff in the project directory that I don't really need in version control or want to put up on Github. This is what an Xcode project basically looks like:

 1 AppName/
 2 ├── AppName
 3 │   ├── Base.lproj
 4 │   │   ├── LaunchScreen.xib
 5 │   │   └── Main.storyboard
 6 │   ├── Images.xcassets
 7 │   │   └── AppIcon.appiconset
 8 │   │       └── Contents.json
 9 │   ├── AppDelegate.swift
10 │   ├── Info.plist
11 │   └── ViewController.swift
12 ├── AppName.xcodeproj
13 │   ├── project.xcworkspace
14 │   │   ├── xcuserdata
15 │   │   │   └── user1.xcuserdatad
16 │   │   │       └── UserInterfaceState.xcuserstate
17 │   │   └── contents.xcworkspacedata
18 │   ├── xcuserdata
19 │   │   └── user1.xcuserdatad
20 │   │       └── xcschemes
21 │   │           ├── AppName.xcscheme
22 │   │           └── xcschememanagement.plist
23 │   └── project.pbxproj
24 └── AppNameTests
25     ├── AppNameTests.swift
26     └── Info.plist

My inclination is to just commit the AppName/ and AppNameTests/ and exclude the AppName.xcodeproj/ directory. What's the recommended way of doing this?

volny
  • 145
  • 1
  • 8
  • possible duplicate of [Git ignore file for Xcode projects](http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects) – jub0bs Aug 08 '15 at 09:45

3 Answers3

1

You'll want to use a .gitignore file to specify which files you don't want to store in GitHub.

Here is how to create the file, and here's what should go in that .gitignore file.

Community
  • 1
  • 1
Michael Dautermann
  • 86,557
  • 17
  • 155
  • 196
1

A better question is what should go in my git ignore file. This is a link to the github repo containing the file you need

https://github.com/github/gitignore/blob/master/Global/Xcode.gitignore

Make sure u start with this file so the files are properly ignored because if you don't some files my be added already and you will have to manually remove them.

Joe Lloyd
  • 8,703
  • 6
  • 44
  • 65
0

The "recommended way" really depends on what you want to do with the project. Typically, there are three choices:

  • check-in only those files which are necessary to build the project
  • add files that reflect development customizations (such as project files that store the names of the currently-visible files in editors)
  • generated files, to make a complete snapshot of the project state.

With the last, you can get into problems with timestamps (while git can be told to know something about commit-times — see Checking out old file WITH original create/modified timestamps — few people do it). Without a system that retrieves files using their original timestamps, you end up with a set of files that demand recompilation each time you do a commit.

Even saving the customization files can be problematic, if you move the files to another part of the filesystem (or attempt to share the files with others).

So... use .gitignore to filter out files not needed to build. But check that you can successfully build using a fresh checkout.

Parth Tamane
  • 1,611
  • 10
  • 24
Thomas Dickey
  • 43,185
  • 7
  • 51
  • 88