简体   繁体   English

我应该 git 忽略 xcodeproject/project.pbxproj 文件吗?

[英]Should I git ignore xcodeproject/project.pbxproj file?

in a XCode project, I offen got xcodeproject/project.pbxproj file changed, but useless info for me, it for compile.在 XCode 项目中,我犯了 xcodeproject/project.pbxproj 文件更改,但对我来说无用的信息,它用于编译。

Should I git ignore this file and xcodeproject/projectxworkspace/username.xcuserdata/UserInterfaceState.xcuserstate file?我应该忽略这个文件和 xcodeproject/projectxworkspace/username.xcuserdata/UserInterfaceState.xcuserstate 文件吗?

Update in the light of Swift Package Manager: If you're building a project as a Swift package - you should definitely ignore this file as it can be generated using file system as source of truth.根据 Swift 包管理器进行更新:如果您将项目构建为 Swift 包 - 您绝对应该忽略此文件,因为它可以使用文件系统作为真实来源生成。 You can do that by using the following command:您可以使用以下命令执行此操作:

$ cd ~/Projects/MyProjectFolder/
$ swift package generate-xcodeproj

For non-SwiftPM answer - see below.对于非 SwiftPM 答案 - 见下文。

This file holds the list of all the files in the project, settings of targets and which files belong to which targets.该文件包含项目中所有文件的列表、目标的设置以及哪些文件属于哪些目标。 It's probably the meatiest file in project bundle.它可能是项目包中最丰富的文件。 You should not ignore this file.不应忽略此文件。 There are few points for this:这有几点:

  1. You may not want to work on this project alone or;您可能不想单独从事这个项目,或者;
  2. You're planning on working on project from different machines;您正计划在不同机器上处理项目;
  3. You'll want to share your code base with others;您将希望与他人共享您的代码库;

That is the only file that you want in your repos from the xcodeproj bundle.这是您在 xcodeproj 包中的存储库中唯一需要的文件。 That file holds all of the info for targets files and build settings.该文件包含目标文件和构建设置的所有信息。

Unfortunately, if your Build Settings includes code signing, you have to re-enter your code-signing entity after every "git pull" if another team member has changed it.不幸的是,如果您的构建设置包含代码签名,那么如果其他团队成员更改了它,您必须在每次“git pull”之后重新输入您的代码签名实体。 It seems to me this info should be in the user settings, not the global pbxproj file.在我看来,这个信息应该在用户设置中,而不是全局 pbxproj 文件中。

If you exclude project.pbxproj Jenkins builds will fail.如果排除 project.pbxproj Jenkins 构建将失败。 So this is important if you use Jenkins.所以如果你使用 Jenkins,这很重要。

project.pbxproj is an important file in the Xcode configuration bundle. project.pbxproj 是 Xcode 配置包中的一个重要文件。 It is responsible for maintaining references to all of the linked files and their groupings, linked frameworks, and most importantly, the project's build settings.它负责维护对所有链接文件及其分组、链接框架以及最重要的项目构建设置的引用。 Because of this, we cannot exclude project.pbxproj from version control.因此,我们不能从版本控制中排除 project.pbxproj。

Here is my general .gitignore for my Xcode Project.这是我的 Xcode 项目的通用.gitignore

# OS X Finder
.DS_Store

# Xcode per-user config
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
*.xcworkspace
xcuserdata

# Build products
build/
*.o
*.LinkFileList
*.hmap

# Automatic backup files
*~.nib/
*.swp
*~
*.dat
*.dep

You can use Xcodegen to generate a pbxproj out of a YAML project specification file then you can ignore pbxproj in git and generate them every time you need.您可以使用 Xcodegen 从 YAML 项目规范文件中生成 pbxproj,然后您可以在 git 中忽略 pbxproj 并在每次需要时生成它们。

I have already used Xcodegen on a second project which has a modular architecture (many pbxprojs) and more then 8 developers is working on it.我已经在第二个项目中使用了 Xcodegen,该项目具有模块化架构(许多 pbxprojs),并且有超过 8 位开发人员正在研究它。

https://github.com/yonaskolb/XcodeGen https://github.com/yonaskolb/XcodeGen

Hope it helps.希望能帮助到你。

I found that I also need to preserve the xcworkspace file(s).我发现我还需要保留 xcworkspace 文件。 If didn't, project with a sub-project broke.如果没有,带有子项目的项目就会失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM