xcode .xcodeproj 文件丢失,分支合并后无法打开

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20105790/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:19:31  来源:igfitidea点击:

.xcodeproj file is lost, cannot be opened after a branch merge

xcodegitmerge

提问by Malloc

I just merged one of the feature branches into develop branch, and since then, when I open Xcode, the .xcodeprojfile seems lost, all files in the project navigator are gone also. click on the .xcodeprojfile I get the following alert: The file couldn't be opened.

我只是将其中一个功能分支合并到开发分支中,从那时起,当我打开 Xcode 时,.xcodeproj文件似乎丢失了,项目导航器中的所有文件也不见了。单击.xcodeproj文件我收到以下警报:The file couldn't be opened.

This is although I am adding .xcodeprojto the .gitignorefile across all the branches. Have you encounter such situation?

这是虽然我在所有分支中添加.xcodeproj.gitignore文件中。你有遇到过这样的情况吗?

回答by Leijonien

This might be caused by unresolved merge conflicts. In that case the XML structure is broken, so Xcode can't read it.

这可能是由未解决的合并冲突引起的。在这种情况下,XML 结构已损坏,因此 Xcode 无法读取它。

In that case you can try this:

在这种情况下,你可以试试这个:

  • In finder right click on the .xcodeproj and choose 'Show Package contents'.

  • Open project.pbxproj in an text editor (this is the actual project file, and has to be valid XML)

  • Check for merge conflicts (look for <<<<<<<and >>>>>>>) and manually resolve them (be careful!), and ensure the file has valid XML format

  • Save the file

  • Try again opening the .xcodeproj with Xcode

  • 在 finder 中右键单击 .xcodeproj 并选择“显示包内容”。

  • 在文本编辑器中打开 project.pbxproj(这是实际的项目文件,必须是有效的 XML)

  • 检查合并冲突(查找<<<<<<<>>>>>>>)并手动解决它们(小心!),并确保文件具有有效的 XML 格式

  • 保存文件

  • 再次尝试使用 Xcode 打开 .xcodeproj

There might be better ways of resolving the conflicts, but this worked for me multiple times. You also might want to check out this question: How to resolve merge conflicts in Git?

可能有更好的方法来解决冲突,但这对我有用多次。您可能还想查看这个问题:如何解决 Git 中的合并冲突?

回答by Gal Blank

Basically, in a project if more than one developer are working and one developer has added some files(it may be .h,.m or any .png) and commits the project including .xcodeProj in source control management.

基本上,在一个项目中,如果有多个开发人员在工作,并且一个开发人员添加了一些文件(可能是 .h、.m 或任何 .png)并在源代码控制管理中提交包括 .xcodeProj 在内的项目。

But due to some reason developer removes files or images from the project and also removes the use of those files or images from the project but forgets to commit the.xcodeProj project file.

但是由于某种原因,开发人员从项目中删除了文件或图像,也从项目中删除了这些文件或图像的使用,但忘记提交 .xcodeProj 项目文件。

If another developer checks out from the source control management and runs the application,he would get error messge error:path file/image name:No such file or directory. So to avoid the error to run the application at our end successfully we can follow below steps

如果另一个开发人员从源代码​​管理中检出并运行该应用程序,他将收到错误消息 error:path file/image name:No such file or directory。因此,为了避免在我们端成功运行应用程序的错误,我们可以按照以下步骤操作

  1. Right click on projectname.xcodeproj and click on showpackagecontent.
  2. There we will get another file as project.pbxproj.
  3. Open that file on text edit and remove the lines where the file or image has been mentioned.
  4. Save the file. And finally run the application it will work.
  1. 右键单击 projectname.xcodeproj 并单击 showpackagecontent。
  2. 在那里我们会得到另一个文件 project.pbxproj。
  3. 在文本编辑中打开该文件并删除提及该文件或图像的行。
  4. 保存文件。最后运行应用程序,它将起作用。