ios 项目 ...xcodeproj 无法打开,因为它缺少 project.pbxproj 文件

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

Project ...xcodeproj cannot be opened because it is missing its project.pbxproj file

iosxcodeversion-controlproject

提问by JeffB6688

I was trying to merge branches and it resulted in the error "Unable to open project… cannot be opened because the project file cannot be parsed". I then tried to take the advice of other stackoverflow responses (namely to edit the file to remove the corruption), but was unable to edit the file. It appears that this is actually a directory, so maybe the structure of this changed with version 4.4 of xcode and since the response to Unable to open project... cannot be opened because the project file cannot be parsedwas written.

我试图合并分支,结果出现错误“无法打开项目...无法打开,因为无法解析项目文件”。然后我尝试听取其他 stackoverflow 响应的建议(即编辑文件以消除损坏),但无法编辑文件。看起来这实际上是一个目录,所以可能这个结构随着 xcode 4.4 版本而改变,并且由于响应无法打开项目...无法打开,因为无法解析项目文件

I then tried to restore myProject.xcodeproj from my time machine backup. This does not work because it says that I don't have permission to access myProject.xcodeproj. I tried to change the permission of that directory, but that did not help.

然后我尝试从我的时间机器备份中恢复 myProject.xcodeproj。这不起作用,因为它说我无权访问 myProject.xcodeproj。我试图更改该目录的权限,但这没有帮助。

I closed and reopened xcode. Now the error is:

我关闭并重新打开了 xcode。现在错误是:

Project ...xcodeproj cannot be opened because it is missing its project.pbxproj file.

项目 ...xcodeproj 无法打开,因为它缺少 project.pbxproj 文件

How can I fix this problem in xcode version 4.4? Can it be restored from the previous snapshot or archive or version in xcode. Can it be restored with time machine. I would like to avoid rebuilding the entire project.

如何在 xcode 4.4 版中解决此问题?是否可以从 xcode 中的先前快照或存档或版本中恢复。可以用时光机恢复吗?我想避免重建整个项目。

采纳答案by JeffB6688

In the end, what I had to do was

最后,我不得不做的是

'cp -R ...TimeMachineBackup/myProject.xcodeproj ...myProjectArea/myProject.xcodeproj'

Then I had to do the following in myProjectArea:

然后我必须在 myProjectArea 中执行以下操作:

git reset --merge

This allowed me to open the project and switch branches back to my main branch.

这允许我打开项目并将分支切换回我的主分支。

not a pleasant experience

不是一个愉快的经历

回答by boxel

The simplest thing to do is probably to

最简单的事情可能是

  1. Checkout myProject.xcodeproj from source control. This will contain the changes that were causing you to be in conflict last time.
  2. Redo the project changes that you made since the last time you committed to source control
  3. commit/push to source control.
  1. 从源代码管理中检出 myProject.xcodeproj。这将包含上次导致您发生冲突的更改。
  2. 重做自上次提交源代码控制以来所做的项目更改
  3. 提交/推送到源代码管理。

In the future, when you get a conflict in the project file, take a look at myProject.xcodeproj/project.pbxproj. Often it's just new files in the project that have been added at the same place. In this case you just need to delete the conflict metadata and resolve the conflicted state.

以后遇到项目文件冲突时,可以查看myProject.xcodeproj/project.pbxproj。通常只是项目中添加到同一位置的新文件。在这种情况下,您只需要删除冲突元数据并解决冲突状态。

回答by Almo

I was able to get this working without commandline stuff like this:

我能够在没有这样的命令行内容的情况下完成这项工作:

  1. Go to Time Machine drive in Finder.
  2. Navigate to desired backup.
  3. Drag it to where I want it. This will complain about not having permission to access the .pbxproj
  4. Right-click the xcodeproj you just dragged out, select "Show Contents".
  5. Right-click the xcodeproj in the Time Machine backup folder, select "Show Contents".
  6. Drag the .pbxproj you see inside to the destnation you just created with the drag in #3.
  1. 前往 Finder 中的 Time Machine 驱动器。
  2. 导航到所需的备份。
  3. 把它拖到我想要的地方。这将抱怨无权访问 .pbxproj
  4. 右键单击刚刚拖出的 xcodeproj,选择“显示内容”。
  5. 右键单击 Time Machine 备份文件夹中的 xcodeproj,选择“显示内容”。
  6. 将您在里面看到的 .pbxproj 拖到您刚刚使用 #3 中的拖动创建的目的地。

Now it should work.

现在它应该可以工作了。

回答by RayInNoIL

For others looking at this issue, the cause in my case turned out to be, that the "conflict text" from a git merge had crept into the actual file:

对于其他关注此问题的人,在我的案例中,原因是 git merge 中的“冲突文本”已潜入实际文件中:

<<<<<<< HEAD
                F0FDA2D61B99EB80007DB99D /* Aptron-mCollegix.xcassets */,
=======
                F08CFAAA1BC1E9EE00A5B6F5 /* Aptron-mCollegix.xcassets */,
>>>>>>> hotfix/Column_Text_Cut-off

opening the project.pbxproj in a text editor made the fix easy.

在文本编辑器中打开 project.pbxproj 使修复变得容易。

回答by Mrk Fldig

Another way this can happen is if you've been using sudo for some reason with pods or the editor - if the file exists under yourApp.xcodeprojectroj directory but xcode is complaining it can't find it - Go to your project root and do:

发生这种情况的另一种方式是,如果您出于某种原因一直在 pod 或编辑器中使用 sudo - 如果该文件存在于 yourApp.xcodeprojectroj 目录下但 xcode 抱怨它找不到它 - 转到您的项目根目录并执行以下操作:

sudo chown -R yourusername:staff ./*

回答by Isaac A

I found my own solution to this issue.

我找到了我自己的解决方案。

The cause of the bug is that the .xcodeproj file is missing its containing pbxproj file, right? This is usually present when you right click your .xcodeproj file and click 'Show Package Contents'. However, in your own case, it's been deleted, through some mistake or other of git versioning.

错误的原因是 .xcodeproj 文件缺少其包含的 pbxproj 文件,对吗?当您右键单击 .xcodeproj 文件并单击“显示包内容”时,通常会出现这种情况。但是,在您自己的情况下,由于某些错误或其他 git 版本控制,它已被删除。

As you can't really generate a .pbxproj file, the solution I found was to go to the original project folder location, which I had used to create the repository. To be honest, you could probably simply create a new project also, as long as it has the same bundle identifier and such! As this project's xcodeproj file will correctly contain a .pbxproj file, replacing the files in the XCode environment with your own project's files will allow the .pbxproj file to update based on these files.

由于您无法真正生成 .pbxproj 文件,因此我找到的解决方案是转到用于创建存储库的原始项目文件夹位置。老实说,您也可以简单地创建一个新项目,只要它具有相同的包标识符等等!由于此项目的 xcodeproj 文件将正确包含 .pbxproj 文件,因此将 XCode 环境中的文件替换为您自己的项目文件将允许 .pbxproj 文件基于这些文件进行更新。

Therefore, after opening this original project folder (/new project folder), in the XCode environment, I then removed all the files within the project, and replaced them with the corresponding files from my project which I was unable to open the xcodeproj file of. I had to fix a few resulting bugs here and there, stuff involving build phases and such not lining up, given you've just copied in a bunch of new files. But after fixing a few small errors, the same project in this new location was eventually able to run no problem!

因此,在打开这个原始项目文件夹(/new project文件夹)后,在XCode环境中,我然后删除了项目中的所有文件,并将它们替换为我的项目中无法打开的xcodeproj文件的相应文件. 鉴于您刚刚复制了一堆新文件,我不得不在这里和那里修复一些由此产生的错误,涉及构建阶段和诸如此类的不排队。但是在修复了一些小错误之后,这个新位置的同一个项目最终能够正常运行!

Finally, I took this successfully running version of the project, and copied in all the files, .xcodeproj file, project folder, test files and all, into the original repository location, deleting the files from the repository before hand to avoid confusing overwriting of files (you can cut and paste the old repository files to a new location if you want to be safe, and don't fancy deleting them!). Then open the project in XCode from the repository location, build and run it on your simulator/device to make sure everything lines up (and fix any small bugs you may need to), and voila! Your project is now able to be committed, pushed, and ran!

最后,我把这个成功运行的项目版本,把所有的文件,.xcodeproj文件,项目文件夹,测试文件等全部复制到原来的存储库位置,事先从存储库中删除文件,以免混淆覆盖文件(如果您想安全,您可以将旧的存储库文件剪切并粘贴到新位置,并且不想删除它们!)。然后从存储库位置在 XCode 中打开项目,在您的模拟器/设备上构建并运行它以确保一切正常(并修复您可能需要的任何小错误),瞧!您的项目现在可以提交、推送和运行了!

This isn't the cleanest solution, and you may have to do similar things across various branches if they've all been corrupted. However, if you don't have access to a Mac time machine, and the other solutions aren't working for you, this is possibly the most straight forward way of having a working .pbxproj file again!

这不是最干净的解决方案,如果它们都已损坏,您可能必须在各个分支上执行类似的操作。但是,如果您无法访问 Mac 时间机器,并且其他解决方案对您不起作用,那么这可能是再次拥有工作 .pbxproj 文件的最直接方法!

Oh, and I removed the .pbxproj from my gitignore. I'm not sure if it's actually find to have it in your gitignore or not, but I'd recommend doing your own research on that subject, I'm not certain myself!

哦,我从我的 gitignore 中删除了 .pbxproj。我不确定它是否真的存在于你的 gitignore 中,但我建议你对这个主题进行自己的研究,我自己也不确定!

Good luck!

祝你好运!

回答by Farhan

If anyone wants to find the missing project.pbxproj file then try opening the .xcodeproj with some code editor and you will find the file there. And note that i had backup of my application in my other pc so i found that file there so you mist have backup of your project somewhere in order for this to work.

如果有人想找到丢失的 project.pbxproj 文件,请尝试使用一些代码编辑器打开 .xcodeproj,您将在那里找到该文件。请注意,我在另一台电脑上备份了我的应用程序,所以我在那里找到了该文件,因此您可以在某处备份您的项目以使其正常工作。