Swift 项目中的版本控制

问题描述 投票:0回答:2

我将使用版本控制系统,例如Github

我的项目是一个 Swift 项目,当我提交到存储库时,我无法确定应排除哪些文件。

  • 我应该提交“Pods”文件夹吗?
  • 我应该提交“xcodeproj”和“xcworkspace”吗?
swift xcode git version-control
2个回答
0
投票

如果有多个开发人员,最好避免 xcworkspace 文件,因为当有多个构建版本或捆绑标识符时,很可能会发生冲突。 xcworkspace 文件中的冲突不会打开项目内的任何文件,除非您解决冲突。您必须使用合并工具或其他一些工具来解决冲突。因此最好避免 xcworkspace 文件。提交pods文件夹就可以了。


0
投票

对 xcodeproj 的简短回答是肯定的,也许适用于 xcworkspace 或 Pods。

我建议您查看 Swift.ignore 文件,Github 使用该文件来获取源代码管理中应包含的内容和应避免的内容的完整清单:

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

在该文件中,关于 xcworkspace 和 Pod 的内容如下:

# 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
© www.soinside.com 2019 - 2024. All rights reserved.