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


当前回答

你应该结账给gitignore。用于Objective-C和Swift。

下面是我正在使用的.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

其他回答

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

.DS_Store
*.swp
*~.nib

build/

*.pbxuser
*.perspective
*.perspectivev3

我还选择了包括:

*.mode1v3
*.mode2v3

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

对于Xcode 4:

xcuserdata

我的是一个。bzrignore,但它是相同的想法:)

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

tm_build_errors用于当我使用TextMate构建我的项目时。它没有Hagelin那么全面,但我认为值得在tm_build_errors行中发布它。

添加一个.gitignore文件

Mac OS x+xcode+swift

这是我如何将.gitignore文件添加到我的Swift项目:

在Xcode中选择你的项目,右键点击→新建组→命名为Git 选择Git文件夹,右键单击→添加新文件 在iOS选项卡中→选择其他→空文件

在这里输入文件名"。gitignore"

确认文件名称和类型

下面是结果结构:

打开该文件并跳过下面的代码


# file

#########################################################################
#                                                                       #
#       Title         - .gitignore file                                 #
#       For           - Mac OS X, Xcode 7 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

########### Mac OS X ###########
# Mac 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

########## Objective-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 repository. Instead, use fastlane to re-generate the

fastlane/report.xml
fastlane/screenshots

嗯,多亏了亚当。他的回答帮助了我很多,但我仍然需要添加更多的条目,因为我想要一个.gitignore文件:

Mac OS x+xcode+swift

参考资料:this和this

我补充说:

xcuserstate
xcsettings

并将我的.gitignore文件放在项目的根目录下。

在承诺和推动之后。然后我跑了起来:

git rm --cached UserInterfaceState.xcuserstate WorkspaceSettings.xcsettings

埋藏在下面的文件夹:

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

然后我再次运行git commit和push

这将创建最新的gitignore文件

iOS开发

git ignore swift,ios >.gitignore

对于macOS开发

git ignore swift,macos >.gitignore