我正在尝试在Swift中重写我的测试应用程序。而现在似乎不可能......或者我错过了一些东西。看:
它看起来像个错误!如果我删除NSTextViewDelegate协议,一切都很好。但我需要这个协议。它适用于Xcode 5和Objective-C。 Xcode 6 beta1和beta2都有这个问题。有什么想法吗?
P.S。:已经提交了bugreport,因为它看起来像是Xcode 6的错误
命令/Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctool chain / usr / bin / swift失败,退出代码为254
0 swift 0x00000001056a4e08 llvm::sys::PrintStackTrace(__sFILE*) + 40
1 swift 0x00000001056a52f4 SignalHandler(int) + 452
2 libsystem_platform.dylib 0x00007fff8a4025aa _sigtramp + 26
3 swift 0x0000000104c94eca void llvm::BitstreamWriter::EmitRecordWithAbbrevImpl<unsigned long long>(unsigned int, llvm::SmallVectorImpl<unsigned long long>&, llvm::StringRef) + 1066
4 swift 0x0000000104c46296 swift::serialization::Serializer::writeConformance(swift::ProtocolDecl const*, swift::ProtocolConformance const*, swift::Decl const*, std::__1::array<unsigned int, 256ul> const&, bool) + 1366
5 swift 0x0000000104c4b33c swift::serialization::Serializer::writeDecl(swift::Decl const*) + 9420
6 swift 0x0000000104c521b5 swift::serialization::Serializer::writeAllDeclsAndTypes() + 8837
7 swift 0x0000000104c52b1e swift::serialization::Serializer::writeAST(llvm::PointerUnion<swift::Module*, swift::SourceFile*>) + 1182
8 swift 0x0000000104c538cb swift::serialization::Serializer::writeToStream(llvm::raw_ostream&, llvm::PointerUnion<swift::Module*, swift::SourceFile*>, swift::SILModule const*, bool, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::StringRef, llvm::StringRef, bool) + 187
9 swift 0x0000000104c5424e swift::serialize(llvm::PointerUnion<swift::Module*, swift::SourceFile*>, char const*, char const*, swift::SILModule const*, bool, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::StringRef, llvm::StringRef, bool) + 398
10 swift 0x0000000104a69679 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 4105
11 swift 0x0000000104a6865d main + 1533
12 libdyld.dylib 0x00007fff8ba125fd start + 1
13 libdyld.dylib 0x0000000000000031 start + 1952373301
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: merge-module command failed due to signal (use -v to see invocation)
Command /Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254
答案 0 :(得分:2)
我遇到了同样的问题。
要解决此问题,我已经将NSTextView子类化,并完成了我自己的委托,如下所示。
class TextViewDelegate: NSObject {
func textView(textView: NSTextView!, doCommandBySelector commandSelector: Selector) -> Bool {
// Do something useful here or just
return false
}
}
class TextView: NSTextView {
let myDelegate = TextViewDelegate()
override func doCommandBySelector(aSelector: Selector) {
if !myDelegate.textView(self, doCommandBySelector: aSelector) {
super.doCommandBySelector(aSelector)
}
}
}
答案 1 :(得分:1)
使用Beta 3,编译不再崩溃。
但是,您必须将textview出口定义为隐式展开
@IBOutlet strong var textView: NSTextView!
否则编译器将停止并显示错误
property 'self.textView' not initialized at super.init call