我尝试在Swift项目中使用一些Objective-C代码,但当我找到另一种获得结果的方法时,最终删除了所述代码和桥接头。除了我尝试通过使用Assistant Editor从IB拖动到.swift文件创建新的插座连接时,一切似乎工作正常(即运行构建,IB连接中的现有插座等)。我认为这与删除我的桥接标题有关,但我不确定是什么。我尝试过运行Clean并重启电脑,没有运气。
编辑:应该提到的问题是无法拖动,在输入插座名称并点击输入后Xcode崩溃了。编辑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
答案 0 :(得分:1)
您的项目似乎已损坏。您可以尝试将代码中的插座拖放到xib文件中。
在.swift文件中输入:
@IBOutlet var varname:Type!
现在将代码拖到xib文件中。
答案 1 :(得分:0)
您是否检查过您的课程和模块是否正确?
您可以点击箭头并显示您的ViewController实现吗?