简体   繁体   中英

What files of an Xcode project should I store in version control?

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?

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 .

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM