Reputation: 1817
I'm trying to rewrite my test app in Swift. And right now it seems impossible... Or I'm missing something. Look:
It looks like a bug! If I remove NSTextViewDelegate protocol, everything is fine. But I need that protocol. And it worked on Xcode 5 and Objective-C. Both Xcode 6 beta1 and beta2 have this issue. Any ideas?
P.S.: have filed bugreport already because it looks like a bug of Xcode 6
Command /Applications/Xcode6-Beta2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 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
Upvotes: 2
Views: 1465
Reputation: 1211
With the Beta 3 the compilation doesn't crash anymore.
However, you have to define a textview outlet as implicitly unwrapped
@IBOutlet strong var textView: NSTextView!
otherwise the compiler stops with the error
property 'self.textView' not initialized at super.init call
Upvotes: 1
Reputation: 111
I have encountered the same problem.
To workaround I have subclassed NSTextView and done my own delegation as follows.
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)
}
}
}
There is an example here https://github.com/sjhorn/SwiftEdit
Upvotes: 2