xcode Interface Builder 无法确定“Main.storyboard”的类型。这可能是由于缺少 SDK

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

Interface Builder was unable to determine the type of "Main.storyboard". This may be due to a missing SDK

iosxcodeswift

提问by metalek

I am getting a strange error whenever I try to view a particular storyboard of a project in Xcode. When I click the storyboard in the file directory I get an alert that reads "Interface Builder was unable to determine the type of "Main.storyboard". This may be due to a missing SDK."

每当我尝试在 Xcode 中查看项目的特定故事板时,都会遇到一个奇怪的错误。当我单击文件目录中的故事板时,我收到一条警告,内容为“Interface Builder 无法确定“Main.storyboard”的类型。这可能是由于缺少 SDK。

This only happens with this particular storyboard, I tried creating another storyboard and I was able to view it just fine. I tried reverting back to a previous version of the project when I was able to open the storyboard, but oddly enough this doesn't fix the error and I get the same alert. I also tried opening the project in an earlier version of Xcode, but to no avail.

这只发生在这个特定的故事板中,我尝试创建另一个故事板,我能够很好地查看它。当我能够打开故事板时,我尝试恢复到项目的先前版本,但奇怪的是这并没有修复错误,我收到了相同的警报。我也尝试在早期版本的 Xcode 中打开该项目,但无济于事。

If it provides more context, I get an error for the storyboard I get when I try to build the project that reads "The operation couldn't be completed. (com.apple.InterfaceBuilder error 2001.)"

如果它提供了更多上下文,当我尝试构建读取“操作无法完成。(com.apple.InterfaceBuilder 错误 2001。)”的项目时,我得到的情节提要错误

Any ideas on what causes this or how to fix it?

关于导致此问题的原因或如何解决此问题的任何想法?

采纳答案by eplazai

This is less complex than you think.

这没有你想象的那么复杂。

The error is because you mistype something on the source code of Main.storyboard, for example I accidentally put an "?" before the first open tag of Main.storyboard.

错误是因为您在 Main.storyboard 的源代码中输入错误,例如我不小心输入了“?” 在 Main.storyboard 的第一个打开标签之前。

1) What you must do is to delete Main.storyboard (select throw to Trash)

1)你必须做的是删除Main.storyboard(选择throw to Trash)

2) Go to Trash, move the Main.storyboard to desktop, open with any text editor and fix the code; then "select all" and "copy".

2) 进入垃圾箱,将 Main.storyboard 移动到桌面,用任何文本编辑器打开并修复代码;然后“全选”和“复制”。

3) On Xcode, create a brand new Main.storyboard and then press Right click on file and select Open As -> Source code, then paste the fixed code that you have on your clipboard.

3) 在 Xcode 上,创建一个全新的 Main.storyboard,然后按右键单击文件并选择 Open As -> Source code,然后粘贴您在剪贴板上的固定代码。

4) Right-click on file and select Open As -> "Interface Builder - Storyboard".

4) 右键单击​​文件并选择打开为 -> “Interface Builder - Storyboard”。

Hope it works for you.

希望对你有效。

回答by gtree

I had the same exact issue. I would not delete it, instead I used grep to locate the file in my project directory i.e. '$grep -r "Main.storyboard" .'

我有同样的问题。我不会删除它,而是使用 grep 在我的项目目录中定位文件,即 '$grep -r "Main.storyboard" 。

Once you find it, you can use an editor (vim or perhaps emacs) to view the actual file, since it may either be corrupted, but in my case I was merging in a branch that appended to the file during automerge:

找到后,您可以使用编辑器(vim 或 emacs)查看实际文件,因为它可能已损坏,但在我的情况下,我在自动合并期间合并到附加到文件的分支中:

    <<<<<<< HEAD 
    document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="gHi-tD-tmJ"
    =======
    document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"
    >>>>>>> develop

If you happened to have this same issue as I did, just delete either the head or the tail of this - whichever you don't want. If you have issues with resolving conflicts, refer here:

如果您碰巧遇到和我一样的问题,只需删除它的头部或尾部 - 无论您不想要哪个。如果您在解决冲突时遇到问题,请参阅此处:

https://githowto.com/resolving_conflicts

https://githowto.com/resolving_conflicts

or

或者

https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line/

https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line/

回答by user2802984

I got this error because I copied and pasted the xml format directly into the xib file. This resulted in unknown file endings. Once I converted to UNIX line endings the solution compiled without the error.

之所以出现这个错误,是因为我将 xml 格式直接复制并粘贴到了 xib 文件中。这导致了未知的文件结尾。一旦我转换为 UNIX 行结束,编译的解决方案就没有错误。

回答by Denis Kutlubaev

If you have resolved conflicts and still have this issue, close XCode and reopen your project. This helped me.

如果您已解决冲突但仍有此问题,请关闭 XCode 并重新打开您的项目。这对我有帮助。

回答by GuestManGhost

For those of you who this technique did not work for, try this and see what happens. Worth a college try.

对于这种技术不适用的人,试试这个,看看会发生什么。值得一试。

Try changing the toolsVersion entry value towards the top of the code in storyboard code editor view. Then navigate to a different file and then back again. See if that resets the storyboard.

尝试将 toolsVersion 条目值更改为故事板代码编辑器视图中代码的顶部。然后导航到不同的文件,然后再返回。看看这是否会重置故事板。

回答by Dhanas Manian

  1. Discard file from woking copy if you have.
  2. and apply the stash.
  3. Resolve conflict and run again.
  1. 如果有,请从工作副本中丢弃文件。
  2. 并应用藏匿处。
  3. 解决冲突并再次运行。

I hope it will work.

我希望它会起作用。