删除 Bridging Header 后从 Interface Builder 拖动时 Xcode 崩溃
Posted
技术标签:
【中文标题】删除 Bridging Header 后从 Interface Builder 拖动时 Xcode 崩溃【英文标题】:Xcode crashes when dragging from Interface Builder after deleting Bridging Header 【发布时间】:2015-07-18 16:26:43 【问题描述】:我尝试在 Swift 项目中使用一些 Objective-C 代码,但当我找到实现结果的替代方法时,最终删除了所述代码和桥接头。除了我尝试通过使用助手编辑器从 IB 拖动到 .swift 文件来创建新的插座连接之外,一切似乎都运行良好(即运行构建、IB 连接中的现有插座等)。我认为这与删除我的桥接头有关,但我不确定是什么。我试过运行 Clean 并重新启动计算机,但没有运气。
编辑:应该提到问题不是无法拖动,而是 Xcode 在输入出口名称并按 Enter 后崩溃。
编辑 2:这是 Xcode 崩溃时的错误输出:
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
ProductBuildVersion: 6D2105
UNCAUGHT EXCEPTION (NSInvalidArgumentException): +[IDESwiftSourceCodeGenerator isTeardownCounterpart:]: unrecognized selector sent to class 0x112de75c0
UserInfo: (null)
Hints: None
Backtrace:
0 0x00007fff94e37024 __exceptionPreprocess (in CoreFoundation)
1 0x00000001011d9bb4 DVTFailureHintExceptionPreprocessor (in DVTFoundation)
2 0x00007fff9212776e objc_exception_throw (in libobjc.A.dylib)
3 0x00007fff94e39fad +[NSObject(NSObject) doesNotRecognizeSelector:] (in CoreFoundation)
4 0x00007fff94d7fe24 ___forwarding___ (in CoreFoundation)
5 0x00007fff94d7f998 _CF_forwarding_prep_0 (in CoreFoundation)
6 0x0000000112d30532 __91-[IDESwiftSourceCodeGenerator prepareToAddPropertyWithName:type:inClassItem:options:error:]_block_invoke_2 (in IDELanguageSupportUI)
7 0x000000010266ceb4 -[IDESourceCodeGenerator prepareToAddSourceCodeForCounterparts:documentLocationForCounterpartBlock:addSourceCodeForCounterpartBlock:options:error:] (in IDEKit)
8 0x0000000112d3013f -[IDESwiftSourceCodeGenerator prepareToAddPropertyWithName:type:inClassItem:options:error:] (in IDELanguageSupportUI)
9 0x0000000112d0b69b -[IDEIBSwiftOutletSourceCodeConnectionContext prepareToInsertSourceCode:] (in IDELanguageSupportUI)
10 0x000000010c3f0a86 -[IBSourceCodeConnectionEndPointHandler insertOrPrepareToInsertSourceCodeForConnectionContext:prepareOrInsertBlock:] (in IDEInterfaceBuilderKit)
11 0x000000010c3f0eda -[IBSourceCodeConnectionEndPointHandler insertCodeForConnectionContext:] (in IDEInterfaceBuilderKit)
12 0x000000010c3f1bbd -[IBSourceCodeConnectionEndPointHandler configuredAndCompletedConnectionWithSourceObject:] (in IDEInterfaceBuilderKit)
13 0x000000010c184b1b -[IBConnectionManager beginOldSchoolConnectingFromObject:withEvent:inWindow:usingSourceLocator:] (in IDEInterfaceBuilderKit)
14 0x000000010c184e74 -[IBConnectionManager beginOldSchoolConnectingFromEditorCanvasFrameController:initialEndPoint:withEvent:] (in IDEInterfaceBuilderKit)
15 0x000000010c270bf5 -[IBEditorCanvasFrameController sendEvent:] (in IDEInterfaceBuilderKit)
16 0x000000010c497689 -[IBViewEditorCanvasFrameController sendEvent:] (in IDEInterfaceBuilderKit)
17 0x000000010c25fe85 -[IBEditorCanvasFrame mouseDragged:] (in IDEInterfaceBuilderKit)
18 0x00007fff8f0cbf12 -[NSWindow _reallySendEvent:isDelayedEvent:] (in AppKit)
19 0x00007fff8ea5dd76 -[NSWindow sendEvent:] (in AppKit)
20 0x00000001024a7168 -[IDEWorkspaceWindow sendEvent:] (in IDEKit)
21 0x00007fff8ea5a312 -[NSApplication sendEvent:] (in AppKit)
22 0x0000000102250c14 -[IDEApplication sendEvent:] (in IDEKit)
23 0x00007fff8e983c68 -[NSApplication run] (in AppKit)
24 0x00007fff8e900354 NSApplicationMain (in AppKit)
25 0x00007fff939b25c9 start (in libdyld.dylib)
abort() called
Application Specific Signatures:
NSInvalidArgumentException
【问题讨论】:
【参考方案1】:您的项目似乎已损坏。您可以尝试将您的插座从您的代码拖放到您的 xib 文件中。
在 .swift 文件中输入:
@IBOutlet var varname:输入!
现在从你的代码拖到你的 xib 文件中。
【讨论】:
效果很好,非常感谢 :) 试图弄清楚项目是如何被破坏的,希望我现在没有为那个桥接头烦恼:/【参考方案2】:您是否检查过您的类和模块是否正确?
您可以点击箭头并显示您的 ViewController 实现吗?
【讨论】:
是的,对不起,我忘了提,这是我检查的第一件事,并显示了正确的实现。还忘了提到问题是当我使用助手编辑器从 xib 拖动到 .swift 时,当我输入插座的名称时出现错误,按回车键,然后 Xcode 崩溃。以上是关于删除 Bridging Header 后从 Interface Builder 拖动时 Xcode 崩溃的主要内容,如果未能解决你的问题,请参考以下文章
# 通过自动创建的 Bridging header 导入 Obj-C 类, Bridging header 似乎找到它但 Swift 类不会
XCode 7.3 破坏了 Bridging-Header.h?
XCode 7.3 破坏了 Bridging-Header.h?