xcode 无法打开故事板(com.apple.InterfaceBuilder 错误 -1。)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16934511/
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
Cannot open storyboard (com.apple.InterfaceBuilder error -1.)
提问by Jeff Lockhart
After several developers were working on the storyboard in one of our apps, we are now getting this error when trying to open the storyboard in Xcode Interface Builder:
在几位开发人员在我们的一个应用程序中处理故事板之后,我们现在在尝试在 Xcode Interface Builder 中打开故事板时收到此错误:
The document "MainStoryboard_iPhone.storyboard" could not be opened. The operation couldn't be completed. (com.apple.InterfaceBuilder error -1.)
Check the console log for additional information.
无法打开文档“MainStoryboard_iPhone.storyboard”。操作无法完成。(com.apple.InterfaceBuilder 错误 -1。)
检查控制台日志以获取其他信息。
We are all running the latest version of Xcode (4.6.2 4H1003) and all changes were made to the storyboard in Interface Builder. There is no additional information showing in the console log. I'm assuming the error is referring to the same console log where log and debug statements appear, which is completely empty.
我们都在运行最新版本的 Xcode (4.6.2 4H1003),并且在 Interface Builder 中对故事板进行了所有更改。控制台日志中没有显示其他信息。我假设错误是指出现日志和调试语句的同一个控制台日志,它是完全空的。
One of the developers receives this same error when trying to open the storyboard in another of our apps I was working on. This storyboard opens fine for me in Xcode on my computer however, so we never bothered to look into the error more at the time (this first occurred a few months ago). But this time, we all get the same error (4 of us have tested opening it on our own computers).
一位开发人员在尝试在我正在开发的另一个应用程序中打开故事板时收到同样的错误。然而,这个故事板在我电脑上的 Xcode 中打开得很好,所以我们当时从不费心去研究这个错误(这第一次发生在几个月前)。但这一次,我们都遇到了同样的错误(我们有 4 个人在自己的电脑上测试过打开它)。
We are using GitHub to manage our source control on both projects, using a few different Git clients. Any ideas as to what is causing this error and how to fix it?
我们使用 GitHub 来管理两个项目的源代码控制,使用几个不同的 Git 客户端。关于导致此错误的原因以及如何修复它的任何想法?
UPDATE:This is the output to /var/logs/system.log on my computer after trying to open the storyboard:
更新:这是在尝试打开情节提要后,我的计算机上 /var/logs/system.log 的输出:
Jun 5 16:38:44 my-computer-host-name Xcode[271]: Exception raised while unarchiving document objects - *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
Jun 5 16:38:45 my-computer-host-name Xcode[271]: [MT] DVTAssertions: Warning in /SourceCache/IDEKit/IDEKit-2113/Framework/Classes/Editor/IDEEditorDocument.m:1364
Details: Message sent to invalidated IBStoryboardDocument instance <IBStoryboardDocument: 0x40ecc34c0>. Backtrace for invalidation:
0 0x000000010d814f86 -[IDEEditorDocument _invalidate] (in IDEKit)
1 0x000000010d883291 -[IDEEditorDocument initForURL:withContentsOfURL:ofType:error:] (in IDEKit)
2 0x00000001103005d0 -[IBDocument initForURL:withContentsOfURL:ofType:error:] (in IDEInterfaceBuilderKit)
3 0x000000010d882efd +[IDEDocumentController _newEditorDocumentWithClass:forURL:withContentsOfURL:ofType:extension:error:] (in IDEKit)
4 0x000000010d882dba -[IDEEditorContext _newEditorDocumentWithClass:forURL:withContentsOfURL:ofType:extension:error:] (in IDEKit)
5 0x000000010d88290c -[IDEEditorContext _openNavigableItem:withContentsOfURL:documentExtension:shouldInstallEditorBlock:] (in IDEKit)
6 0x000000010d991628 -[IDEEditorContext _notifyDelegateAndOpenNavigableItem:withContentsURL:documentExtensionIdentifier:locationToSelect:annotationRepresentedObject:stateDictionary:annotationWantsIndicatorAnimation:exploreAnnotationRepresentedObject:highlightSelection:] (in IDEKit)
7 0x000000010d8bfe7b -[IDEEditorContext _notifyDelegateAndOpenEditorOpenSpecifier:updateHistory:] (in IDEKit)
8 0x000000010d8bf99c -[IDEEditorContext _openEditorOpenSpecifier:updateHistory:] (in IDEKit)
9 0x000000010d8bf8ba -[IDEEditorContext openEditorOpenSpecifier:] (in IDEKit)
10 0x000000010d8cbf40 -[IDEEditorGeniusMode openEditorOpenSpecifier:editorContext:] (in IDEKit)
11 0x000000010d8bf76e -[IDEEditorArea _openEditorOpenSpecifier:editorContext:takeFocus:] (in IDEKit)
12 0x000000010d9a3174 __108+[IDEEditorCoordinator _doOpenEditorOpenSpecifier:forWorkspaceTabController:editorContext:target:takeFocus:]_block_invoke (in IDEKit)
13 0x000000010d8bf6cc +[IDEEditorCoordinator _doOpenWithWorkspaceTabController:editorContext:target:allowFallback:documentURL:usingBlock:] (in IDEKit)
14 0x000000010d8bf12d +[IDEEditorCoordinator _doOpenEditorOpenSpecifier:forWorkspaceTabController:editorContext:target:takeFocus:] (in IDEKit)
15 0x000000010d8bed45 -[_IDEOpenRequest _runIfNecessary] (in IDEKit)
16 0x00007fff8bfde395 __NSFireDelayedPerform (in Foundation)
17 0x00007fff8b169804 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ (in CoreFoundation)
18 0x00007fff8b16931d __CFRunLoopDoTimer (in CoreFoundation)
19 0x00007fff8b14ead9 __CFRunLoopRun (in CoreFoundation)
20 0x00007fff8b14e0e2 CFRunLoopRunSpecific (in CoreFoundation)
21 0x00007fff8ac57eb4 RunCurrentEventLoopInMode (in HIToolbox)
22 0x00007fff8ac57c52 ReceiveNextEventCommon (in HIToolbox)
23 0x00007fff8ac57ae3 BlockUntilNextEventMatchingListInMode (in HIToolbox)
24 0x00007fff85f5d563 _DPSNextEvent (in AppKit)
25 0x00007fff85f5ce22 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit)
26 0x00007fff85f541d3 -[NSApplication run] (in AppKit)
27 0x00007fff85ef8c06 NSApplicationMain (in AppKit)
28 0x000000010cbc9b6f (in Xcode)
29 0x000000010cbc9b00 (in Xcode)
30 0x0000000000000002
Object: <IBStoryboardDocument: 0x40ecc34c0>
Method: -updateChangeCount:
Thread: <NSThread: 0x40030a220>{name = (null), num = 1}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
And this is the log output on the other dev's computer after trying to open the storyboard in the other project that we get this same error on (this is the storyboard that opens fine on my computer):
这是在另一个开发人员的计算机上尝试打开我们遇到相同错误的另一个项目中的故事板后的日志输出(这是在我的计算机上可以正常打开的故事板):
Jun 5 17:20:13 other-dev-computer-host-name Xcode[157]: Exception raised while unarchiving document objects - *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
Jun 5 17:20:13 other-dev-computer-host-name Xcode[157]: [MT] DVTAssertions: Warning in /SourceCache/IDEKit/IDEKit-2113/Framework/Classes/Editor/IDEEditorDocument.m:1364
Details: Message sent to invalidated IBStoryboardDocument instance <IBStoryboardDocument: 0x409ec3340>. Backtrace for invalidation:
0 0x000000010d746f86 -[IDEEditorDocument _invalidate] (in IDEKit)
1 0x000000010d7b5291 -[IDEEditorDocument initForURL:withContentsOfURL:ofType:error:] (in IDEKit)
2 0x00000001102755d0 -[IBDocument initForURL:withContentsOfURL:ofType:error:] (in IDEInterfaceBuilderKit)
3 0x000000010d7b4efd +[IDEDocumentController _newEditorDocumentWithClass:forURL:withContentsOfURL:ofType:extension:error:] (in IDEKit)
4 0x000000010d7b4dba -[IDEEditorContext _newEditorDocumentWithClass:forURL:withContentsOfURL:ofType:extension:error:] (in IDEKit)
5 0x000000010d7b490c -[IDEEditorContext _openNavigableItem:withContentsOfURL:documentExtension:shouldInstallEditorBlock:] (in IDEKit)
6 0x000000010d7d9c96 -[IDEEditorContext _openNavigableItem:withContentsOfURL:shouldInstallEditorBlock:] (in IDEKit)
7 0x000000010d8c3667 -[IDEEditorContext _notifyDelegateAndOpenNavigableItem:withContentsURL:documentExtensionIdentifier:locationToSelect:annotationRepresentedObject:stateDictionary:annotationWantsIndicatorAnimation:exploreAnnotationRepresentedObject:highlightSelection:] (in IDEKit)
8 0x000000010d7f1e7b -[IDEEditorContext _notifyDelegateAndOpenEditorOpenSpecifier:updateHistory:] (in IDEKit)
9 0x000000010d7f199c -[IDEEditorContext _openEditorOpenSpecifier:updateHistory:] (in IDEKit)
10 0x000000010d7f18ba -[IDEEditorContext openEditorOpenSpecifier:] (in IDEKit)
11 0x000000010d7f189f -[IDEEditorModeViewController openEditorOpenSpecifier:editorContext:] (in IDEKit)
12 0x000000010d7f176e -[IDEEditorArea _openEditorOpenSpecifier:editorContext:takeFocus:] (in IDEKit)
13 0x000000010d8d5174 __108+[IDEEditorCoordinator _doOpenEditorOpenSpecifier:forWorkspaceTabController:editorContext:target:takeFocus:]_block_invoke (in IDEKit)
14 0x000000010d7f16cc +[IDEEditorCoordinator _doOpenWithWorkspaceTabController:editorContext:target:allowFallback:documentURL:usingBlock:] (in IDEKit)
15 0x000000010d7f112d +[IDEEditorCoordinator _doOpenEditorOpenSpecifier:forWorkspaceTabController:editorContext:target:takeFocus:] (in IDEKit)
16 0x000000010d7f0d45 -[_IDEOpenRequest _runIfNecessary] (in IDEKit)
17 0x00007fff98955395 __NSFireDelayedPerform (in Foundation)
18 0x00007fff909bd804 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ (in CoreFoundation)
19 0x00007fff909bd31d __CFRunLoopDoTimer (in CoreFoundation)
20 0x00007fff909a2ad9 __CFRunLoopRun (in CoreFoundation)
21 0x00007fff909a20e2 CFRunLoopRunSpecific (in CoreFoundation)
22 0x00007fff92e5eeb4 RunCurrentEventLoopInMode (in HIToolbox)
23 0x00007fff92e5ec52 ReceiveNextEventCommon (in HIToolbox)
24 0x00007fff92e5eae3 BlockUntilNextEventMatchingListInMode (in HIToolbox)
25 0x00007fff96036563 _DPSNextEvent (in AppKit)
26 0x00007fff96035e22 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit)
27 0x00007fff9602d1d3 -[NSApplication run] (in AppKit)
28 0x00007fff95fd1c06 NSApplicationMain (in AppKit)
29 0x000000010caf9b6f (in Xcode)
30 0x000000010caf9b00 (in Xcode)
31 0x0000000000000002
Object: <IBStoryboardDocument: 0x409ec3340>
Method: -updateChangeCount:
Thread: <NSThread: 0x40030a1a0>{name = (null), num = 1}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
Both log outputs are very similar. There is an additional line in the call stack of the 2nd output at line 6: [IDEEditorContext _openNavigableItem:withContentsOfURL:shouldInstallEditorBlock:] (in IDEKit)
. And line 11 (10 on the 1st) references the method IDEEditorModeViewController
instead of IDEEditorGeniusMode
. Otherwise the log outputs are identical.
两个日志输出非常相似。有在第6行中的第二输出的调用堆栈的附加行:[IDEEditorContext _openNavigableItem:withContentsOfURL:shouldInstallEditorBlock:] (in IDEKit)
。第 11 行(第 10 行)引用了该方法IDEEditorModeViewController
而不是IDEEditorGeniusMode
. 否则日志输出是相同的。
Note, this 2nd storyboard that we originally received this error on would not have had a problem with Git merge conflicts as I am the only developer to have worked on this storyboard. I've never needed to merge commits to this repository at all as I'm the sole contributing developer on it.
请注意,我们最初收到此错误的第二个故事板不会有 Git 合并冲突的问题,因为我是唯一在此故事板上工作的开发人员。我从来不需要将提交合并到这个存储库,因为我是它的唯一贡献开发人员。
采纳答案by Joshua DeWald
Is the project using any custom fonts?
该项目是否使用任何自定义字体?
I just spent all day long dealing with the exact same issue (tried multiple computers with multiple XCode versions), and immediately after I installed the two custom fonts we had in the project the Storyboards were able to open.
我一整天都在处理完全相同的问题(尝试了多台具有多个 XCode 版本的计算机),并且在我安装了项目中的两种自定义字体后,Storyboards 立即能够打开。
I received a mix of both the "invalidate" exception as well as an array exception. And the array exception led a fellow developer to a similar StackOverflow questionwhere he realized we had custom fonts.
我收到了“无效”异常和数组异常的混合。数组异常将一位开发人员带到了一个类似的 StackOverflow 问题,他意识到我们有自定义字体。
回答by Tobias
As Marcelstates: this sometimes occurs on a merge. But his answer does not point to anything specific, so let me give a hint what we had to deal with a few times. We had some unreadable storyboards after a merge on a file that was changed locally.
正如马塞尔所说:这有时发生在合并中。但是他的回答并没有指向任何具体的东西,所以让我提示一下我们不得不处理的几次。在合并本地更改的文件后,我们有一些不可读的故事板。
We could fix them by opening the storyboard in text-mode and checking every segue reference
in the end of the storyboard file:
我们可以通过在文本模式下打开故事板并检查segue reference
故事板文件末尾的每一个来修复它们:
<inferredMetricsTieBreakers>
<segue reference="gJw-Ph-JeV"/>
<segue reference="Olp-GN-hLL"/>
<segue reference="aFq-vB-ngK"/>
</inferredMetricsTieBreakers>
Search the storyboard for the quoted values. If you cannot find a second match for this string, comment out this line with <!-- -->
. After removing all invalid segue references, Xcode was able to open the storyboards again.
在情节提要中搜索引用的值。如果找不到此字符串的第二个匹配项,请使用<!-- -->
. 删除所有无效的 segue 引用后,Xcode 能够再次打开故事板。
回答by Marcel
This problem is being caused by merging each others storyboard changes. The storyboard format is XML based. When you make changes, these changes are being saved in the project file. Xcode seems to be non-deterministic in the way it saves the structure of this file, things can be sorted differently, objects can appear in different places in the structure. This doesn't matter when you are working on your own, but when two or more people make a change to the storyboard, merges can get very ugly. Even though git seems to be able to merge the files fine, the structure of the file gets corrupted and you won't be able to open your storyboards.
这个问题是由合并彼此的故事板更改引起的。故事板格式是基于 XML 的。当您进行更改时,这些更改将保存在项目文件中。Xcode 在保存该文件结构的方式上似乎是不确定的,事物可以以不同的方式排序,对象可以出现在结构中的不同位置。当您自己工作时,这无关紧要,但是当两个或更多人对故事板进行更改时,合并会变得非常丑陋。尽管 git 似乎能够很好地合并文件,但文件的结构已损坏,您将无法打开故事板。
Commit your changes to storyboards early and push. Allways pull before making changes to the storyboard. Don't merge, pick one version and continue.
尽早提交对故事板的更改并推动。在对故事板进行更改之前,请务必拉取。不要合并,选择一个版本并继续。
You are probably better off treating your xcode project files as binary files in your git repository. See http://robots.thoughtbot.com/post/33796217972/xcode-and-git-bridging-the-gapfor a good reading on this.
您最好将 xcode 项目文件视为 git 存储库中的二进制文件。请参阅http://robots.thoughtbot.com/post/33796217972/xcode-and-git-bridging-the-gap以获得有关此内容的良好阅读。
As for your situation, you probably have to checkout a know good version of your project file and rebuild your changes in the storyboard from there.
至于您的情况,您可能必须检出项目文件的已知良好版本,并从那里重建故事板中的更改。
回答by Yup.
This worked for me:
这对我有用:
in environment with error delete .storyboard file (move to trash).
在有错误的环境中删除 .storyboard 文件(移至垃圾箱)。
copy .storyboard from environment that works and send it (solo file) to the environment that does not work (email, thumb drive, Skype, however).
从有效的环境中复制 .storyboard 并将其(单独文件)发送到无效的环境(但是,电子邮件、拇指驱动器、Skype)。
drag and drop the .storyboard back into the broken environment (copy and save)
将 .storyboard 拖放到损坏的环境中(复制并保存)
fixed.
固定的。