忽略文件
git
是一种代码管理的方式;但是,并不是所有的代码都需要进行管理更新的,所以就会有一个配置文件,指明那些文件不需要git
管控。
在git
里,这个定义不管控的文件是一个隐藏文件.gitignore

Object-C
各种语言的忽略文件内容不相同,在GitHub上有一个专门的项目,搜集了各种语言的忽略内容,非常好用Object-C忽略文件。一般情况下,直接用就可以了。比如Object-C的内容如下:
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
## Obj-C/Swift specific
*.hmap
## App packaging
*.ipa
*.dSYM.zip
*.dSYM
# 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/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace
# 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 screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/
Pod文件夹要忽略吗?
-
如果忽略,那么只保存了
podfile
,那么每个下载代码的人都需要执行pod install
命令。 -
如果不忽略,那么
Pod
文件夹下的第三方库直接以代码的形式放在自己的git
代码库中。普通开发者通过git
下载之后,不需要进行任何pod
相关操作,就可以直接编译运行工程。
-
两种选择都有各自的道理,也都有人在用。在这里,我选择第2种。
pod
相关操作只需要有一个人负责就行,其他人不需要知道。 -
默认提供的
.gitignore
文件也是选择第2种:
# 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/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace
默认是注释掉的,也就是Pod文件夹不忽略,第三方库代码要管控;选第1种的话只要把相关注释取消就行了。
.xcodeproj文件
这个文件很特殊,在mac上看好像是一个文件,但是在其他操作系统上看,比如Windows平台上看,它其实是一个文件夹。
Xcode 工程文件“.xcodeproj”文件夹解析
-
project.pbxproj
文件;这个很重要,冲突有很多来自这里,要谨慎对待 -
xcuserdata
文件夹;这个每次打开都会修改,一定要忽略,不然会被烦死的; -
xcshareddata
文件夹;这个基本上不会用到,不过不能忽略; -
project.xcworkspace
文件夹 ;这个文件很重要,用了Pod,要双击这个才能打开工程;
默认提供的.gitignore
文件也是这么设置的,只忽略xcuserdata
文件夹:
## User settings
xcuserdata/
网友评论