编辑 XIB 时 XCode 7.3 崩溃

Posted

技术标签:

【中文标题】编辑 XIB 时 XCode 7.3 崩溃【英文标题】:XCode 7.3 crashes when editing XIB 【发布时间】:2016-06-14 18:57:41 【问题描述】:

我有一个编译和运行良好的 XCode 项目,但是当我将元素添加到特定 XIB 的 UI 时,当我尝试保存或 XCode 失去焦点时,它会使 XCode 崩溃。查看崩溃的错误数据,它似乎是与 NSTableHeader 相关的断言失败,但我不明白从那里去哪里?我没有使用自动布局,这是一个 OSX 应用程序。

Process:               Xcode [2505]
Path:                  /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier:            com.apple.dt.Xcode
Version:               7.3.1 (10188.1)
Build Info:            IDEFrameworks-10188001000000000~3
App Item ID:           497799835
App External ID:       817226719
Code Type:             X86-64 (Native)
Parent Process:        ??? [1]
Responsible:           Xcode [2505]
User ID:               501

Date/Time:             2016-06-14 11:30:04.824 -0700
OS Version:            Mac OS X 10.11.5 (15F34)
Report Version:        11
Anonymous UUID:        20048F22-546D-D351-6F8C-D73FF28F4650


Time Awake Since Boot: 67000 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
ProductBuildVersion: 7D1014
ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEInterfaceBuilder/IDEInterfaceBuilder-10117/InterfaceBuilderKit/Document/ObjectContainer/IBObjectContainer.m:513
Details:  Can't get the OID of an object not in the document: <NSTableHeaderView: 0x7fc5daeefd90>
Object:   <IBObjectContainer: 0x7fc5dae4eeb0>
Method:   -objectIDForObject:
Thread:   <NSThread: 0x7fc5d3e17e80>number = 1, name = main
Hints:   None
Backtrace:
  0   -[IDEAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in IDEKit)
  1   _DVTAssertionHandler (in DVTFoundation)
  2   _DVTAssertionFailureHandler (in DVTFoundation)
  3   -[IBObjectContainer objectIDForObject:] (in IDEInterfaceBuilderKit)
  4   -[IBDocument objectIDForObject:] (in IDEInterfaceBuilderKit)
  5   -[IBDocument documentArchiver:referenceIDForObject:referenceType:] (in IDEInterfaceBuilderKit)
  6   -[IBDocumentArchiver referenceIDForObject:withReferenceType:] (in IDEInterfaceBuilderKit)
  7   -[IBDocumentArchiver archiveObjectReference:referenceType:forKey:] (in IDEInterfaceBuilderKit)
  8   -[IBDocumentArchiver archiveObjectReference:referenceType:forKey:defaultValue:] (in IDEInterfaceBuilderKit)
  9   -[NSTableView(IBDocumentArchivingGenerator) archiveWithDocumentArchiver:] (in IDEInterfaceBuilderCocoaIntegration)
 10   __51-[IBDocumentArchiver archiveObject:forOptionalKey:]_block_invoke (in IDEInterfaceBuilderKit)
 11   -[IBDocumentArchiver recurseWithElementNamed:forObject:kind:invokingBlock:] (in IDEInterfaceBuilderKit)
 12   -[IBDocumentArchiver archiveObject:forOptionalKey:] (in IDEInterfaceBuilderKit)
 13   __59-[IBDocumentArchiver archiveArray:withName:forOptionalKey:]_block_invoke (in IDEInterfaceBuilderKit)
 14   -[IBDocumentArchiver recurseWithElementNamed:forObject:kind:invokingBlock:] (in IDEInterfaceBuilderKit)
 15   -[IBDocumentArchiver archiveArray:withName:forOptionalKey:] (in IDEInterfaceBuilderKit)
 16   -[IBDocumentArchiver archiveArray:withName:forOptionalKey:defaultValue:] (in IDEInterfaceBuilderKit)
 17   -[NSView(IBViewIntegration) ibArchiveSubviews:] (in IDEInterfaceBuilderKit)
 18   -[NSView(IBDocumentArchivingGenerator) archiveWithDocumentArchiver:] (in IDEInterfaceBuilderKit)
 19   -[IBNSCustomView(IBDocumentArchivingGenerator) archiveWithDocumentArchiver:] (in IDEInterfaceBuilderCocoaIntegration)
 20   __51-[IBDocumentArchiver archiveObject:forOptionalKey:]_block_invoke (in IDEInterfaceBuilderKit)
 21   -[IBDocumentArchiver recurseWithElementNamed:forObject:kind:invokingBlock:] (in IDEInterfaceBuilderKit)
 22   -[IBDocumentArchiver archiveObject:forOptionalKey:] (in IDEInterfaceBuilderKit)
 23   __59-[IBDocumentArchiver archiveArray:withName:forOptionalKey:]_block_invoke (in IDEInterfaceBuilderKit)
 24   -[IBDocumentArchiver recurseWithElementNamed:forObject:kind:invokingBlock:] (in IDEInterfaceBuilderKit)
 25   -[IBDocumentArchiver archiveArray:withName:forOptionalKey:] (in IDEInterfaceBuilderKit)
 26   -[IBDocument archiveTopLevelObjects:] (in IDEInterfaceBuilderKit)
 27   -[IBDocument archiveAndVerifyArchivingOfTopLevelObjects:] (in IDEInterfaceBuilderKit)
 28   -[IBDocument archivePlatformIndependentDataWithDocumentArchiver:] (in IDEInterfaceBuilderKit)
 29   -[IBDocument archiveDocument:] (in IDEInterfaceBuilderKit)
 30   -[IBDocumentArchiver recurseWithElementNamed:forObject:kind:invokingBlock:] (in IDEInterfaceBuilderKit)
 31   -[IBDocumentArchiver archiveDocument:withType:compatibilityVersion:] (in IDEInterfaceBuilderKit)
 32   -[IBDocumentArchiver dataFromArchiveDocument:withType:compatibilityVersion:] (in IDEInterfaceBuilderKit)
 33   __46-[IBDocument fileWrapperOfType:options:error:]_block_invoke (in IDEInterfaceBuilderKit)
 34   -[IBDocument fileWrapperOfType:options:error:] (in IDEInterfaceBuilderKit)
 35   -[IBDocument fileWrapperOfType:error:] (in IDEInterfaceBuilderKit)
 36   -[NSDocument writeToURL:ofType:error:] (in AppKit)
 37   -[IBDocument writeToURL:ofType:error:] (in IDEInterfaceBuilderKit)
 38   -[NSDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] (in AppKit)
 39   -[IBDocument writeToURL:ofType:forSaveOperation:originalContentsURL:error:] (in IDEInterfaceBuilderKit)
 40   -[NSDocument _writeSafelyToURL:ofType:forSaveOperation:forceTemporaryDirectory:error:] (in AppKit)
 41   -[NSDocument _writeSafelyToURL:ofType:forSaveOperation:error:] (in AppKit)
 42   -[NSDocument writeSafelyToURL:ofType:forSaveOperation:error:] (in AppKit)
 43   -[IDEEditorDocument writeSafelyToURL:ofType:forSaveOperation:error:] (in IDEKit)
 44   __66-[NSDocument saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_22463 (in AppKit)
 45   __66-[NSDocument saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke2460 (in AppKit)
 46   __66-[NSDocument saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_22313 (in AppKit)
 47   __50-[IDEEditorDocument continueFileAccessUsingBlock:]_block_invoke.74 (in IDEKit)
 48   -[NSDocument continueFileAccessUsingBlock:] (in AppKit)
 49   -[IDEEditorDocument continueFileAccessUsingBlock:] (in IDEKit)
 50   __101-[NSDocument _fileCoordinator:asynchronouslyCoordinateReadingContentsAndWritingItemAtURL:byAccessor:]_block_invoke_2 (in AppKit)
 51   __68-[IDEEditorDocument continueAsynchronousWorkOnMainThreadUsingBlock:]_block_invoke (in IDEKit)
 52   __62-[NSDocumentController(NSInternal) _onMainThreadInvokeWorker:]_block_invoke2079 (in AppKit)
 53   __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ (in CoreFoundation)
 54   __CFRunLoopDoBlocks (in CoreFoundation)
 55   __CFRunLoopRun (in CoreFoundation)
 56   CFRunLoopRunSpecific (in CoreFoundation)
 57   RunCurrentEventLoopInMode (in HIToolbox)
 58   ReceiveNextEventCommon (in HIToolbox)
 59   _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox)
 60   _DPSNextEvent (in AppKit)
 61   -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit)
 62   -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in DVTKit)
 63   -[NSApplication run] (in AppKit)
 64   NSApplicationMain (in AppKit)
 65  0x000000010c51a39b (in Xcode)
 66   start (in libdyld.dylib)

abort() called

【问题讨论】:

【参考方案1】:

我遇到了类似的问题,我认为这是因为我的 XIB 文件很旧(来自 XCode 4.6 或更早版本)。从那时起,xml-schema 发生了重大变化。 (请参阅this article。)我能够通过从 Time Machine 中获取 XCode 6 并在应用程序中与 XCode 7 一起复制来对我需要进行的 XIB 进行更改。我没有尝试使用 XCode 6 打开任何项目,但我直接打开了 XIB 并在项目之外进行了我需要进行的更改。

奇怪的是,我只能在几周前修改这些 XIB 文件之一。 XCode (7) 然后用新模式完全重写了 XML,现在编辑那个 XIB 没有问题。此外,如果我尝试将 XIB 升级到更新的模式,即使 XCode 6 现在也会崩溃。 (我想我只能编辑我的 XIB,因为 XCode 6 与 XCode 7 不同,仍然可以编辑旧架构而不升级它。)

我认为 Apple 可能在过去几周推出了 XCode 外部的软件更新,但仍然破坏了 xml 升级。或者是我做过的其他事情,但我想不出它会是什么。

FWIW:我在 10.11.5,所以至少 XCode 6 的 Interface Builder 部分仍然可以在最新的操作系统上运行。

编辑:我能够升级 XML,因此能够使用稍微复杂的解决方案在 XCode 7.3.1 中编辑 XIB:

    使用 Fusion 或 Parallels 创建 10.8 虚拟机。 在虚拟机中安装 XCode 5.1.1。 (您可以找到下载链接here。) 在 XCode 5.1.1 中打开 XIB 并升级它。您现在可以打开它并将其保存在 XCode 7 中。

【讨论】:

谢谢,您的回答很有道理。我的项目已有好几年了,我怀疑您对 XML 模式更改的看法是正确的。幸运的是,我能够将我的问题追踪到可以删除的 NSTableView 上,现在一切看起来都很开心。

以上是关于编辑 XIB 时 XCode 7.3 崩溃的主要内容,如果未能解决你的问题,请参考以下文章

编辑情节提要时 Xcode Interface Builder 崩溃

Xcode 7.3 在设置断点或应用程序崩溃时崩溃

Xcode 堆栈视图导致崩溃?

XCode在XIB项目问题中查找和替换

选择主情节提要或 xib 时 Xcode 6 GM 崩溃

打开旧的 xib 文件时 xcode 5.1 崩溃