xcode 无法打开文档“Main.storyboard”

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

The document "Main.storyboard" could not be be opened

iosiphonexcodegitstoryboard

提问by anyName

I'm using Git and we are 2 people coding together. I pulled my friend's code, run it and it worked as it should be. Then I merged our parts and cleaned conflicts (almost all of them were in storyboard). Since i'm doing this merge process for a while, i'm not all stranger for these details. However, when i run the merged version of code, i get the error:

我正在使用 Git,我们是 2 个人一起编码。我拉了我朋友的代码,运行它,它按预期工作。然后我合并了我们的部分并清除了冲突(几乎所有这些都在故事板中)。由于我正在执行此合并过程一段时间,因此我对这些细节并不陌生。但是,当我运行合并版本的代码时,出现错误:

The document "Main.storyboard" could not be opened. The operation couldn't be completed. (com.apple.InterfaceBuilder error -1.)

无法打开文档“Main.storyboard”。操作无法完成。(com.apple.InterfaceBuilder 错误 -1。)

I can't open storyboard as interface builder either. When i try it, I get the same error. I read previous postabout this error but as I mentioned, I can open and run both versions of code in my XCode before merge. Thus, there is not a font or attributed string problem.

我也无法将故事板作为界面构建器打开。当我尝试时,我得到同样的错误。我阅读了有关此错误的上一篇文章,但正如我所提到的,我可以在合并之前在 XCode 中打开并运行两个版本的代码。因此,不存在字体或属性字符串问题。

What may be the problem?

可能是什么问题?

回答by aircraft

I got this issue, after I solve the conflictswhich is merged by svn.

在我解决了conflictssvn.

I could only see the source code of my storyboard, I could not open my storyboardas interface builder. So, after my struggle,

我只能看到我的源代码storyboard,我无法打开我的storyboardas interface builder。所以,经过我的挣扎,

1)I delete the topside space line in my storyboardsource code

1)我删除了storyboard源代码中的顶部空格行

2)and close my Xcodeand simulator

2)并关闭我的Xcodesimulator

3)restart my project

3)重新启动我的项目

it becomes regular, oops, the space line on the source code will affect our storyboard

变成常规了,哎呀,源代码上的空格行会影响我们的storyboard

回答by Cong Tran

I guess your storyboard still have confliction.View your storyborad as source code, then fix all conflictions. After all, open it again as Interface builder

我猜你的故事板仍然有冲突。查看你的故事板作为源代码,然后修复所有冲突。毕竟,再次打开它作为Interface builder

Example

例子

回答by robfitzgerald

I had to create a new Storyboard file. Then cut and paste the "scenes" tags from the old and put into the new. I then had to delete the old Storyboard from the project in order for the project to build successfully!

我必须创建一个新的 Storyboard 文件。然后剪切并粘贴旧的“​​场景”标签并放入新标签中。然后我不得不从项目中删除旧的 Storyboard,以便项目成功构建!

回答by Shaked Sayag

For me the only thing that worked was to create a new storyboard file, open the old and the new storyboards as source code, and copy the xml from the old to the new storyboard. I didn't take the whole xml, just the scope of the <scenes> </scenes>

对我来说,唯一有效的是创建一个新的故事板文件,打开旧的和新的故事板作为源代码,然后将 xml 从旧的故事板复制到新的故事板。我没有拿整个xml,只是范围<scenes> </scenes>

回答by Mussa Charles

Fast way to fix

快速修复方法

  1. Copy the storyboard Id shown on the error prompt window
  2. Right click on your storyboard
  3. Choose Open as => Source Code
  4. Search the id and delete one of the duplicateID and you are done!
  1. 复制错误提示窗口中显示的storyboard Id
  2. 右键单击您的故事板
  3. 选择打开为 => 源代码
  4. 搜索 id 并删除其中的一个 duplicateID 就大功告成了!

回答by Dambar Bista

i would suggest , right click on any of the files and click on finder then you will have what you need and drag and drop

我建议,右键单击任何文件并单击查找器,然后您将拥有所需的内容并拖放

回答by Mikhail Glotov

I guess the problem is that storyboards don't merge very well, I think it is better to init your UI from code so there will be no troubles during merges. Anyway you should try to rollback and merge it again.

我想问题是故事板不能很好地合并,我认为最好从代码中初始化您的 UI,这样合并过程中就不会出现问题。无论如何,您应该尝试回滚并再次合并它。

回答by vaibby

there are conflicts in Storyboard. You can take last working code of storyboard from github. select storyboard select version editor and copy last working storyboard and replace xml with existing xml.

Storyboard 中存在冲突。您可以从 github 获取故事板的最后工作代码。选择故事板选择版本编辑器并复制最后一个工作故事板并用现有的 xml 替换 xml。

回答by Nicolas Miari

As other mentioned, there are likely merge conflicts in the storyboard file.

正如其他人提到的,故事板文件中可能存在合并冲突。

If you can't easily solve the conflict by either picking --oursor --theirs, you will have to perform the merge manually in the storyboard file.

如果您无法通过选择--ours或轻松解决冲突--theirs,则必须在故事板文件中手动执行合并。

What I do is open in in a text editor (e.g., TextEdit.app - but make sure it opens documents as plain text, in Preferences).

我所做的是在文本编辑器中打开(例如,TextEdit.app - 但确保它在首选项中以纯文本形式打开文档)。

Then, locate any occurrence of the git conflict markers (or a portion thereof, e.g., "<<<<<"), and pick the code fragment that you want to leave (and remove the other, of course).

然后,找到任何出现的 git 冲突标记(或其一部分,例如“<<<<<”),并选择您想要留下的代码片段(当然,删除另一个)。



EDIT:As Cong Tranmentioned (and I forgot), you can open storyboards as source code from within Xcode itself (see his answer).

编辑:正如Cong Tran提到的(我忘记了),您可以从 Xcode 本身中将故事板作为源代码打开(请参阅他的回答)。