当Git与Xcode一起使用时,我应该在.gitignore中包含哪些文件?


当前回答

这将创建最新的gitignore文件

iOS开发

git ignore swift,ios >.gitignore

对于macOS开发

git ignore swift,macos >.gitignore

其他回答

对于Xcode 4,我还添加了:

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

基于Mercurial的这个指南,我的.gitignore包括:

.DS_Store
*.swp
*~.nib

build/

*.pbxuser
*.perspective
*.perspectivev3

我还选择了包括:

*.mode1v3
*.mode2v3

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

对于Xcode 4:

xcuserdata

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

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

它可能在任何给定的时间都是合理正确的。

我使用以下在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/

最棒的是,

gitignore.io

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