ios 我应该 git 忽略 xcodeproject/project.pbxproj 文件吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8026429/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Should I git ignore xcodeproject/project.pbxproj file?
提问by qichunren
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 文件吗?
回答by Eimantas
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. You can do that by using the following command:
根据 Swift 包管理器进行更新:如果您将项目构建为 Swift 包 - 您绝对应该忽略此文件,因为它可以使用文件系统作为真实来源生成。您可以使用以下命令执行此操作:
$ 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 notignore this file. There are few points for this:
该文件包含项目中所有文件的列表、目标的设置以及哪些文件属于哪些目标。它可能是项目包中最丰富的文件。您不应忽略此文件。这有几点:
- You may not want to work on this project alone or;
- You're planning on working on project from different machines;
- You'll want to share your code base with others;
- 您可能不想单独从事这个项目,或者;
- 您正计划在不同的机器上处理项目;
- 您将希望与他人共享您的代码库;
回答by Grady Player
That is the only file that you want in your repos from the xcodeproj bundle. That file holds all of the info for targets files and build settings.
这是您在 xcodeproj 包中的存储库中唯一需要的文件。该文件包含目标文件和构建设置的所有信息。
回答by Julius Smith
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. It seems to me this info should be in the user settings, not the global pbxproj file.
不幸的是,如果您的构建设置包含代码签名,那么如果其他团队成员更改了它,您必须在每次“git pull”之后重新输入您的代码签名实体。在我看来,这个信息应该在用户设置中,而不是全局 pbxproj 文件中。
回答by Joseph Bolade Caxton-Idowu
If you exclude project.pbxproj Jenkins builds will fail. So this is important if you use Jenkins.
如果排除 project.pbxproj Jenkins 构建将失败。所以如果你使用 Jenkins,这很重要。
回答by Cyril Cermak
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.
希望能帮助到你。
回答by James
project.pbxproj is an important file in the Xcode configuration bundle. 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 是 Xcode 配置包中的一个重要文件。它负责维护对所有链接文件及其分组、链接框架以及最重要的项目构建设置的引用。因此,我们不能从版本控制中排除 project.pbxproj。
Here is my general .gitignore
for my Xcode Project.
这是我的.gitignore
Xcode 项目的概述。
# 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
回答by Paul Cezanne
I found that I also need to preserve the xcworkspace file(s). If didn't, project with a sub-project broke.
我发现我还需要保留 xcworkspace 文件。如果没有,带有子项目的项目就会失败。