Git忽略了Xcode项目的文件。

时间:2022-02-26 14:03:47

Which files should I include in .gitignore when using Git in conjunction with Xcode?

在使用Git与Xcode一起使用Git时,应该包括哪些文件?

19 个解决方案

#1


632  

Mods: Please do not approve edits to this answer. So far, every edit has been INCORRECT and causes DATA LOSS. Please leave this answer alone!

Mods:请不要批准对这个答案的编辑。到目前为止,每个编辑都是错误的,导致数据丢失。请把这个答案单独留下!


If you want to edit this answer ... don't. Read the whole thing first - there's an easy way for you to make your own fork, and if that's not enough then comment on it.

如果你想编辑这个答案…不喜欢。先把整件事通读一遍——有一种简单的方法可以让你自己拿一把叉子,如果这还不够,那就评论一下。


I was previously using the top-voted answer, but it needs a bit of cleanup, so here it is re-done for Xcode 4, with some improvements.

我之前使用的是顶部投票的答案,但是它需要一些清理,所以在这里重新为Xcode 4做了一些改进。

I've researched every file in this list, but several of them do not exist in Apple's official xcode docs, so I had to go on Apple mailing lists.

我已经研究了这个列表中的每个文件,但是其中有几个并不存在于苹果的官方xcode文档中,所以我不得不去苹果邮件列表。

Apple continues to add undocumented files, potentially corrupting our live projects. This IMHO is unacceptable, and I've now started logging bugs against it each time they do so. I know they don't care, but maybe it'll shame one of them into treating developers more fairly.

苹果继续增加无证文件,可能会破坏我们的现场项目。这种IMHO是不可接受的,我现在已经开始在每次它们这样做时对它进行日志记录。我知道他们不在乎,但也许会让其中一个更公平地对待开发人员。


If you need to customize, here's a gist you can fork: https://gist.github.com/3786883

如果您需要定制,这里有一个您可以使用的要点:https://gist.github.com/3786883。


#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
#    15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://*.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2015 updates:
# - Fixed typo in "xccheckout" line - thanks to @lyck for pointing it out!
# - Fixed the .idea optional ignore. Thanks to @hashier for pointing this out
# - Finally added "xccheckout" to the ignore. Apple still refuses to answer support requests about this, but in practice it seems you should ignore it.
# - minor tweaks from Jona and Coeur (slightly more precise xc* filtering/names)
# 2014 updates:
# - appended non-standard items DISABLED by default (uncomment if you use those tools)
# - removed the edit that an SO.com moderator made without bothering to ask me
# - researched CocoaPods .lock more carefully, thanks to Gokhan Celiker
# 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 files are usually local-only file-synchronization on the local FS that should NOT go in git)
# c.f. the "OPTIONAL" section at bottom though, for tool-specific variations!
#
# In particular, if you're using CocoaPods, you'll want to comment-out this line:
*.lock


#
# profile - REMOVED temporarily (on double-checking, 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://*.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


####
# Xcode 4 - semi-personal settings
#
# Apple Shared data that Apple put in the wrong folder
# c.f. http://*.com/a/19260712/153422
#     FROM ANSWER: Apple says "don't ignore it"
#     FROM COMMENTS: Apple is wrong; Apple code is too buggy to trust; there are no known negative side-effects to ignoring Apple's unofficial advice and instead doing the thing that actively fixes bugs in Xcode
# Up to you, but ... current advice: ignore it.
*.xccheckout

#
#
# OPTION 1: ---------------------------------
#     throw away ALL personal settings (including custom schemes!
#     - unless they are "shared")
# As per build/ and DerivedData/, this ought to have a trailing slash
#
# 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 *requires* git v1.8.2 or above; you may need to upgrade to latest OS X,
#    or manually install git over the top of the OS X version
# 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
#     /project.xcworkspace/
#       contents.xcworkspacedata
#       /xcuserdata/
#         /(your name)/xcuserdatad/
#           UserInterfaceState.xcuserstate
#     /xcshareddata/
#       /xcschemes/
#         (shared scheme name).xcscheme
#     /xcuserdata/
#       /(your name)/xcuserdatad/
#         (private scheme).xcscheme
#         xcschememanagement.plist
#
#

####
# 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

####
# OPTIONAL: Some well-known tools that people use side-by-side with Xcode / iOS development
#
# NB: I'd rather not include these here, but gitignore's design is weak and doesn't allow
#     modular gitignore: you have to put EVERYTHING in one file.
#
# COCOAPODS:
#
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#what-is-a-podfilelock
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
#!Podfile.lock
#
# RUBY:
#
# c.f. http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
#
#!Gemfile.lock
#
# IDEA:
#
# c.f. https://www.jetbrains.com/objc/help/managing-projects-under-version-control.html?search=workspace.xml
# 
#.idea/workspace.xml
#
# TEXTMATE:
#
# -- UNVERIFIED: c.f. http://*.com/a/50283/153422
#
#tm_build_errors

####
# UNKNOWN: recommended by others, but I can't discover what these files are
#

#2


272  

Based on this guide for Mercurial my .gitignore includes:

根据这篇Mercurial的指南,gitignore包括:

.DS_Store
*.swp
*~.nib

build/

*.pbxuser
*.perspective
*.perspectivev3

I've also chosen to include:

我还选择了包括:

*.mode1v3
*.mode2v3

which, according to this Apple mailing list post, are "user-specific project settings".

根据这个苹果邮件列表,它是“用户特定的项目设置”。

And for Xcode 4:

在Xcode 4:

xcuserdata

#3


59  

Regarding the 'build' directory exclusion -

关于“构建”目录排除-。

If you place your build files in a different directory from your source, as I do, you don't have the folder in the tree to worry about.

如果您将构建文件放置在源文件的不同目录中,如我所做的那样,您就不会有树中需要担心的文件夹。

This also makes life simpler for sharing your code, preventing bloated backups, and even when you have dependencies to other Xcode projects (while require the builds to be in the same directory as each other)

这也使得共享代码、防止冗余备份、甚至当您对其他Xcode项目有依赖性时(同时要求构建在相同的目录中)更加简单。

You can grab an up-to-date copy from the Github gist https://gist.github.com/708713

您可以从Github的gist https://gist.github.com/708713中获取最新的副本。

My current .gitignore file is

我现在的。gitignore文件。

# Mac OS X
*.DS_Store

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/

# Generated files
*.o
*.pyc


#Python modules
MANIFEST
dist/
build/

# Backup files
*~.nib

#4


54  

For Xcode 4 I also add:

对于Xcode 4,我还添加:

YourProjectName.xcodeproj/xcuserdata/*
YourProjectName.xcodeproj/project.xcworkspace/xcuserdata/*

#5


23  

I included these suggestions in a Gist I created on Github: http://gist.github.com/137348

我在Github上创建的一个要点中包括了这些建议:http://gist.github.com/137348。

Feel free to fork it, and make it better.

你可以用叉子叉它,让它更好。

#6


13  

The people of GitHub have exhaustive and documented .gitignore files for Xcode projects:

GitHub的人员对Xcode项目有详尽的、文档化的.gitignore文件:

Swift: https://github.com/github/gitignore/blob/master/Swift.gitignore

斯威夫特:https://github.com/github/gitignore/blob/master/Swift.gitignore

Objective-C: https://github.com/github/gitignore/blob/master/Objective-C.gitignore

objective - c:https://github.com/github/gitignore/blob/master/Objective-C.gitignore

#7


12  

I'm using both AppCode and XCode. So .idea/ should be ignored.

我正在使用AppCode和XCode。所以。idea/应该被忽略。

append this to Adam's .gitignore

把这个附加到亚当的。gitignore。

####
# AppCode
.idea/

#8


10  

Mine is a .bzrignore, but same idea :)

我的是。bzrignore,但同样的想法

.DS_Store
*.mode1v3
*.pbxuser
*.perspectivev3
*.tm_build_errors

the tm_build_errors is for when I use TextMate to build my project. Not quite as comprehensive as Hagelin but I thought it was worth posting for the tm_build_errors line.

当我使用TextMate来构建我的项目时,tm_build_errors就是for。不像Hagelin那样全面,但我认为它值得发布tm_build_errors行。

#9


10  

Heres a script I made to auto create your .gitignore and .gitattributes files using Xcode... I hacked it together with a few other people's stuff. Have fun!

这是我用Xcode自动创建您的.gitignore和.gitattributes文件的脚本。我把它和其他一些人的东西一起砍了。玩得开心!

Xcode-Git-User-Script

Xcode-Git-User-Script

No warranties... I suck at most of this - so use at your own peril

没有保证…我最讨厌这个——所以用你自己的危险。

#10


10  

You should checkout gitignore.io for Objective C and Swift

你应该付款gitignore。目标C和Swift的io。

Here is the .gitignore file I'm using

这是我正在使用的.gitignore文件。

# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
*.xcworkspace
!default.xcworkspace

#CocoaPods
Pods

#11


8  

adding .gitignore file for

添加.gitignore文件

MAC OS X + XCode + Swift

MAC OS X + XCode + Swift。

This is how, I have added .gitignore file into my Swift project

这就是我在Swift项目中添加了.gitignore文件的方法。

  1. Select you project in XCode and Right Click --> New Group --> Name it "Git"
  2. 在XCode中选择您的项目,右键单击——>新组——>名称为“Git”
  3. Select Git folder and Right click --> Add new file
  4. 选择Git文件夹并右键单击——>添加新文件。
  5. Within iOS tab -->select Other --> empty file
  6. 在iOS选项卡中——>选择其他——>空文件。

Git忽略了Xcode项目的文件。

  1. give the file name here ".gitignore"
  2. 在这里输入文件名"。gitignore"

Git忽略了Xcode项目的文件。

  1. Confirm the file name and type
  2. 确认文件名和类型。

Git忽略了Xcode项目的文件。

Here is the result structure

这是结果结构。

Git忽略了Xcode项目的文件。

  1. open file and past below code
  2. 打开文件和过去的代码。

# file

#########################################################################
#                                                                       #
#       Title         - .gitignore file                                 #
#       For           - MAC OSX , Xcode7 and Swift Source projects      #
#       Updated by    - Ramdhan Choudhary                               #
#       Updated on    - 13 - November - 2015                            #
#                                                                       #
#########################################################################

########### Xcode ###########
# Xcode temporary files that should never be committed

## Build generated
build/
DerivedData

# NB: NIB/XIB files still exist even on Storyboard projects, so we want this
*~.nib
*.swp

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata

## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint
*.xcscheme

########### OSX ###########
# OS X temporary files that should never be committed

.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

########## Obj-C/Swift specific ##########
*.hmap
*.ipa

# 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

fastlane/report.xml
fastlane/screenshots

Well thanks to Adam, his answer helped me a lot but still I had to add few more entry as I wanted .gitignore for

多亏了亚当,他的回答帮了我很大的忙,但我还是得再增加一些我想要的条目。

MAC OS X + XCode + Swift

MAC OS X + XCode + Swift。

References : this and this

参考文献:这个和这个。

#12


6  

For XCode 5 I add:

对于XCode 5,我添加:

####
# Xcode 5 - VCS metadata
#
*.xccheckout

From Berik's Answer

从Berik语的回答

#13


5  

I use the following .gitignore file generated in gitignore.io:

我使用gitignore.io中生成的.gitignore文件。

### Xcode ###
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.xcuserstate


### Objective-C ###
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
Pods/

#14


4  

I've added:

我补充说:

xcuserstate
xcsettings

and placed my .gitignore file at the root of my project.

把我的。gitignore文件放在项目的根目录。

After committing and pushing. I then ran:

后提交和推动。然后我跑:

git rm --cached UserInterfaceState.xcuserstate WorkspaceSettings.xcsettings

buried with the folder below:

埋在下面的文件夹:

<my_project_name>/<my_project_name>.xcodeproj/project.xcworkspace/xcuserdata/<my_user_name>.xcuserdatad/

I then ran git commit and push again

然后,我运行git提交并再次推送。

#15


2  

Here's the .gitignore that GitHub uses by default for new Xcode repositories:

以下是GitHub默认为新Xcode存储库使用的.gitignore:

https://github.com/github/gitignore/blob/master/Objective-C.gitignore

https://github.com/github/gitignore/blob/master/Objective-C.gitignore

It's likely to be reasonably correct at any given time.

它在任何时候都可能是合理的。

#16


2  

best of all,

最重要的是,

gitignore.io

gitignore.io

Go and choose your language, then it'll give you the file.

去选择你的语言,然后它会给你文件。

#17


0  

We did find that even if you add the .gitignore and the .gitattribte the *.pbxproj file can get corrupted. So we have a simple plan.

我们确实发现,即使你加了。gitignore和。gitattribte *。pbxproj文件会被损坏。所以我们有一个简单的计划。

Every person that codes in office simply discards the changes made to this file. In the commit we simple mention the files that are added into the source. And then push to the server. Our integration manager than pulls and sees the commit details and adds the files into the resources.

每个在办公室编码的人都简单地丢弃了对这个文件的修改。在提交中,我们简单地提到添加到源代码中的文件。然后推送到服务器。我们的集成管理器将会看到提交细节并将文件添加到资源中。

Once he updates the remote everyone will always have a working copy. In case something is missing then we inform him to add it in and then pull once again.

一旦他更新了遥控器,每个人都会有一个工作副本。万一有什么东西不见了,我们通知他把它加进去再拉一次。

This has worked out for us without any issues.

这对我们没有任何问题。

#18


0  

I recommend using joe to generate a .gitignore file.

我建议使用joe生成.gitignore文件。

For an iOS project run the following command:

对于一个iOS项目运行以下命令:

$ joe g osx,xcode > .gitignore

$ joe g osx,xcode > .gitignore。

It will generate this .gitignore:

它会生成这个。gitignore:

.DS_Store
.AppleDouble
.LSOverride

Icon
._*

.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

build/
DerivedData

*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata

*.xccheckout
*.moved-aside
*.xcuserstate

#19


0  

Use https://www.gitignore.io/ to generate, and add the mac, cocoaPods files like bellow:

使用https://www.gitignore.io/生成,并添加mac, cocoaPods文件,如bellow:

## Mac
.DS_Store

## cocoaPods
Pod

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno

#1


632  

Mods: Please do not approve edits to this answer. So far, every edit has been INCORRECT and causes DATA LOSS. Please leave this answer alone!

Mods:请不要批准对这个答案的编辑。到目前为止,每个编辑都是错误的,导致数据丢失。请把这个答案单独留下!


If you want to edit this answer ... don't. Read the whole thing first - there's an easy way for you to make your own fork, and if that's not enough then comment on it.

如果你想编辑这个答案…不喜欢。先把整件事通读一遍——有一种简单的方法可以让你自己拿一把叉子,如果这还不够,那就评论一下。


I was previously using the top-voted answer, but it needs a bit of cleanup, so here it is re-done for Xcode 4, with some improvements.

我之前使用的是顶部投票的答案,但是它需要一些清理,所以在这里重新为Xcode 4做了一些改进。

I've researched every file in this list, but several of them do not exist in Apple's official xcode docs, so I had to go on Apple mailing lists.

我已经研究了这个列表中的每个文件,但是其中有几个并不存在于苹果的官方xcode文档中,所以我不得不去苹果邮件列表。

Apple continues to add undocumented files, potentially corrupting our live projects. This IMHO is unacceptable, and I've now started logging bugs against it each time they do so. I know they don't care, but maybe it'll shame one of them into treating developers more fairly.

苹果继续增加无证文件,可能会破坏我们的现场项目。这种IMHO是不可接受的,我现在已经开始在每次它们这样做时对它进行日志记录。我知道他们不在乎,但也许会让其中一个更公平地对待开发人员。


If you need to customize, here's a gist you can fork: https://gist.github.com/3786883

如果您需要定制,这里有一个您可以使用的要点:https://gist.github.com/3786883。


#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
#    15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://*.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2015 updates:
# - Fixed typo in "xccheckout" line - thanks to @lyck for pointing it out!
# - Fixed the .idea optional ignore. Thanks to @hashier for pointing this out
# - Finally added "xccheckout" to the ignore. Apple still refuses to answer support requests about this, but in practice it seems you should ignore it.
# - minor tweaks from Jona and Coeur (slightly more precise xc* filtering/names)
# 2014 updates:
# - appended non-standard items DISABLED by default (uncomment if you use those tools)
# - removed the edit that an SO.com moderator made without bothering to ask me
# - researched CocoaPods .lock more carefully, thanks to Gokhan Celiker
# 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 files are usually local-only file-synchronization on the local FS that should NOT go in git)
# c.f. the "OPTIONAL" section at bottom though, for tool-specific variations!
#
# In particular, if you're using CocoaPods, you'll want to comment-out this line:
*.lock


#
# profile - REMOVED temporarily (on double-checking, 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://*.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


####
# Xcode 4 - semi-personal settings
#
# Apple Shared data that Apple put in the wrong folder
# c.f. http://*.com/a/19260712/153422
#     FROM ANSWER: Apple says "don't ignore it"
#     FROM COMMENTS: Apple is wrong; Apple code is too buggy to trust; there are no known negative side-effects to ignoring Apple's unofficial advice and instead doing the thing that actively fixes bugs in Xcode
# Up to you, but ... current advice: ignore it.
*.xccheckout

#
#
# OPTION 1: ---------------------------------
#     throw away ALL personal settings (including custom schemes!
#     - unless they are "shared")
# As per build/ and DerivedData/, this ought to have a trailing slash
#
# 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 *requires* git v1.8.2 or above; you may need to upgrade to latest OS X,
#    or manually install git over the top of the OS X version
# 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
#     /project.xcworkspace/
#       contents.xcworkspacedata
#       /xcuserdata/
#         /(your name)/xcuserdatad/
#           UserInterfaceState.xcuserstate
#     /xcshareddata/
#       /xcschemes/
#         (shared scheme name).xcscheme
#     /xcuserdata/
#       /(your name)/xcuserdatad/
#         (private scheme).xcscheme
#         xcschememanagement.plist
#
#

####
# 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

####
# OPTIONAL: Some well-known tools that people use side-by-side with Xcode / iOS development
#
# NB: I'd rather not include these here, but gitignore's design is weak and doesn't allow
#     modular gitignore: you have to put EVERYTHING in one file.
#
# COCOAPODS:
#
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#what-is-a-podfilelock
# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
#!Podfile.lock
#
# RUBY:
#
# c.f. http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
#
#!Gemfile.lock
#
# IDEA:
#
# c.f. https://www.jetbrains.com/objc/help/managing-projects-under-version-control.html?search=workspace.xml
# 
#.idea/workspace.xml
#
# TEXTMATE:
#
# -- UNVERIFIED: c.f. http://*.com/a/50283/153422
#
#tm_build_errors

####
# UNKNOWN: recommended by others, but I can't discover what these files are
#

#2


272  

Based on this guide for Mercurial my .gitignore includes:

根据这篇Mercurial的指南,gitignore包括:

.DS_Store
*.swp
*~.nib

build/

*.pbxuser
*.perspective
*.perspectivev3

I've also chosen to include:

我还选择了包括:

*.mode1v3
*.mode2v3

which, according to this Apple mailing list post, are "user-specific project settings".

根据这个苹果邮件列表,它是“用户特定的项目设置”。

And for Xcode 4:

在Xcode 4:

xcuserdata

#3


59  

Regarding the 'build' directory exclusion -

关于“构建”目录排除-。

If you place your build files in a different directory from your source, as I do, you don't have the folder in the tree to worry about.

如果您将构建文件放置在源文件的不同目录中,如我所做的那样,您就不会有树中需要担心的文件夹。

This also makes life simpler for sharing your code, preventing bloated backups, and even when you have dependencies to other Xcode projects (while require the builds to be in the same directory as each other)

这也使得共享代码、防止冗余备份、甚至当您对其他Xcode项目有依赖性时(同时要求构建在相同的目录中)更加简单。

You can grab an up-to-date copy from the Github gist https://gist.github.com/708713

您可以从Github的gist https://gist.github.com/708713中获取最新的副本。

My current .gitignore file is

我现在的。gitignore文件。

# Mac OS X
*.DS_Store

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/

# Generated files
*.o
*.pyc


#Python modules
MANIFEST
dist/
build/

# Backup files
*~.nib

#4


54  

For Xcode 4 I also add:

对于Xcode 4,我还添加:

YourProjectName.xcodeproj/xcuserdata/*
YourProjectName.xcodeproj/project.xcworkspace/xcuserdata/*

#5


23  

I included these suggestions in a Gist I created on Github: http://gist.github.com/137348

我在Github上创建的一个要点中包括了这些建议:http://gist.github.com/137348。

Feel free to fork it, and make it better.

你可以用叉子叉它,让它更好。

#6


13  

The people of GitHub have exhaustive and documented .gitignore files for Xcode projects:

GitHub的人员对Xcode项目有详尽的、文档化的.gitignore文件:

Swift: https://github.com/github/gitignore/blob/master/Swift.gitignore

斯威夫特:https://github.com/github/gitignore/blob/master/Swift.gitignore

Objective-C: https://github.com/github/gitignore/blob/master/Objective-C.gitignore

objective - c:https://github.com/github/gitignore/blob/master/Objective-C.gitignore

#7


12  

I'm using both AppCode and XCode. So .idea/ should be ignored.

我正在使用AppCode和XCode。所以。idea/应该被忽略。

append this to Adam's .gitignore

把这个附加到亚当的。gitignore。

####
# AppCode
.idea/

#8


10  

Mine is a .bzrignore, but same idea :)

我的是。bzrignore,但同样的想法

.DS_Store
*.mode1v3
*.pbxuser
*.perspectivev3
*.tm_build_errors

the tm_build_errors is for when I use TextMate to build my project. Not quite as comprehensive as Hagelin but I thought it was worth posting for the tm_build_errors line.

当我使用TextMate来构建我的项目时,tm_build_errors就是for。不像Hagelin那样全面,但我认为它值得发布tm_build_errors行。

#9


10  

Heres a script I made to auto create your .gitignore and .gitattributes files using Xcode... I hacked it together with a few other people's stuff. Have fun!

这是我用Xcode自动创建您的.gitignore和.gitattributes文件的脚本。我把它和其他一些人的东西一起砍了。玩得开心!

Xcode-Git-User-Script

Xcode-Git-User-Script

No warranties... I suck at most of this - so use at your own peril

没有保证…我最讨厌这个——所以用你自己的危险。

#10


10  

You should checkout gitignore.io for Objective C and Swift

你应该付款gitignore。目标C和Swift的io。

Here is the .gitignore file I'm using

这是我正在使用的.gitignore文件。

# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
*.xcworkspace
!default.xcworkspace

#CocoaPods
Pods

#11


8  

adding .gitignore file for

添加.gitignore文件

MAC OS X + XCode + Swift

MAC OS X + XCode + Swift。

This is how, I have added .gitignore file into my Swift project

这就是我在Swift项目中添加了.gitignore文件的方法。

  1. Select you project in XCode and Right Click --> New Group --> Name it "Git"
  2. 在XCode中选择您的项目,右键单击——>新组——>名称为“Git”
  3. Select Git folder and Right click --> Add new file
  4. 选择Git文件夹并右键单击——>添加新文件。
  5. Within iOS tab -->select Other --> empty file
  6. 在iOS选项卡中——>选择其他——>空文件。

Git忽略了Xcode项目的文件。

  1. give the file name here ".gitignore"
  2. 在这里输入文件名"。gitignore"

Git忽略了Xcode项目的文件。

  1. Confirm the file name and type
  2. 确认文件名和类型。

Git忽略了Xcode项目的文件。

Here is the result structure

这是结果结构。

Git忽略了Xcode项目的文件。

  1. open file and past below code
  2. 打开文件和过去的代码。

# file

#########################################################################
#                                                                       #
#       Title         - .gitignore file                                 #
#       For           - MAC OSX , Xcode7 and Swift Source projects      #
#       Updated by    - Ramdhan Choudhary                               #
#       Updated on    - 13 - November - 2015                            #
#                                                                       #
#########################################################################

########### Xcode ###########
# Xcode temporary files that should never be committed

## Build generated
build/
DerivedData

# NB: NIB/XIB files still exist even on Storyboard projects, so we want this
*~.nib
*.swp

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata

## Other
*.xccheckout
*.moved-aside
*.xcuserstate
*.xcscmblueprint
*.xcscheme

########### OSX ###########
# OS X temporary files that should never be committed

.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

########## Obj-C/Swift specific ##########
*.hmap
*.ipa

# 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

fastlane/report.xml
fastlane/screenshots

Well thanks to Adam, his answer helped me a lot but still I had to add few more entry as I wanted .gitignore for

多亏了亚当,他的回答帮了我很大的忙,但我还是得再增加一些我想要的条目。

MAC OS X + XCode + Swift

MAC OS X + XCode + Swift。

References : this and this

参考文献:这个和这个。

#12


6  

For XCode 5 I add:

对于XCode 5,我添加:

####
# Xcode 5 - VCS metadata
#
*.xccheckout

From Berik's Answer

从Berik语的回答

#13


5  

I use the following .gitignore file generated in gitignore.io:

我使用gitignore.io中生成的.gitignore文件。

### Xcode ###
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.xcuserstate


### Objective-C ###
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
Pods/

#14


4  

I've added:

我补充说:

xcuserstate
xcsettings

and placed my .gitignore file at the root of my project.

把我的。gitignore文件放在项目的根目录。

After committing and pushing. I then ran:

后提交和推动。然后我跑:

git rm --cached UserInterfaceState.xcuserstate WorkspaceSettings.xcsettings

buried with the folder below:

埋在下面的文件夹:

<my_project_name>/<my_project_name>.xcodeproj/project.xcworkspace/xcuserdata/<my_user_name>.xcuserdatad/

I then ran git commit and push again

然后,我运行git提交并再次推送。

#15


2  

Here's the .gitignore that GitHub uses by default for new Xcode repositories:

以下是GitHub默认为新Xcode存储库使用的.gitignore:

https://github.com/github/gitignore/blob/master/Objective-C.gitignore

https://github.com/github/gitignore/blob/master/Objective-C.gitignore

It's likely to be reasonably correct at any given time.

它在任何时候都可能是合理的。

#16


2  

best of all,

最重要的是,

gitignore.io

gitignore.io

Go and choose your language, then it'll give you the file.

去选择你的语言,然后它会给你文件。

#17


0  

We did find that even if you add the .gitignore and the .gitattribte the *.pbxproj file can get corrupted. So we have a simple plan.

我们确实发现,即使你加了。gitignore和。gitattribte *。pbxproj文件会被损坏。所以我们有一个简单的计划。

Every person that codes in office simply discards the changes made to this file. In the commit we simple mention the files that are added into the source. And then push to the server. Our integration manager than pulls and sees the commit details and adds the files into the resources.

每个在办公室编码的人都简单地丢弃了对这个文件的修改。在提交中,我们简单地提到添加到源代码中的文件。然后推送到服务器。我们的集成管理器将会看到提交细节并将文件添加到资源中。

Once he updates the remote everyone will always have a working copy. In case something is missing then we inform him to add it in and then pull once again.

一旦他更新了遥控器,每个人都会有一个工作副本。万一有什么东西不见了,我们通知他把它加进去再拉一次。

This has worked out for us without any issues.

这对我们没有任何问题。

#18


0  

I recommend using joe to generate a .gitignore file.

我建议使用joe生成.gitignore文件。

For an iOS project run the following command:

对于一个iOS项目运行以下命令:

$ joe g osx,xcode > .gitignore

$ joe g osx,xcode > .gitignore。

It will generate this .gitignore:

它会生成这个。gitignore:

.DS_Store
.AppleDouble
.LSOverride

Icon
._*

.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

build/
DerivedData

*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata

*.xccheckout
*.moved-aside
*.xcuserstate

#19


0  

Use https://www.gitignore.io/ to generate, and add the mac, cocoaPods files like bellow:

使用https://www.gitignore.io/生成,并添加mac, cocoaPods文件,如bellow:

## Mac
.DS_Store

## cocoaPods
Pod

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

### Xcode Patch ###
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
/*.gcno