当我使用库Eureka
编译Swift代码时,出现错误"由于信号导致命令失败:分段错误:11">。我使用的是Xcode 7.3版(7D175)。我的情况与这个问题类似。
在上面的问题中,有些人在Eureka上遇到了同样的错误,但这对我没有帮助。我刚刚创建了一个新项目,并完成了"pod安装"。然后我添加了"AgeRow.swift"。所以,这个项目是最低限度的。
下面是一个导致分割错误的小样本。
请确保此样本依赖Eureka 1.5.0。
我正在编写名为AgeInlineRow
的自定义行。当我注释掉AgeInlineRow
类时,就可以编译示例了。也就是说,其他代码似乎不是错误的原因。
public final class AgeInlineRow: _AgeInlineRow, RowType, InlineRowType {
required public init(tag: String?) {
super.init(tag: tag)
onExpandInlineRow { cell, row, _ in
let color = cell.detailTextLabel?.textColor
row.onCollapseInlineRow { cell, _, _ in
cell.detailTextLabel?.textColor = color
}
cell.detailTextLabel?.textColor = cell.tintColor
}
}
public override func customDidSelect() {
super.customDidSelect()
if !isDisabled {
toggleInlineRow()
}
}
public func setupInlineRow(inlineRow: InlineRow) {
inlineRow.year_options = self.year_options
inlineRow.month_options = self.month_options
inlineRow.displayValueFor = self.displayValueFor
}
}
当我删除InlineRowType
协议并修改代码进行编译时,这个项目就可以编译了。所以,我想原因是InlineRowType
协议,这是我调试能力的限制。我不知道怎样才能绕过这个问题。我已经复制了尤里卡的PickerInlineRow
代码并进行了修改。当然PickerInlineRow
不会导致分割错误。
如果你能具体说明原因,我将不胜感激。
下面是错误消息。
0 swift 0x0000000108f344eb llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x0000000108f337d6 llvm::sys::RunSignalHandlers() + 70
2 swift 0x0000000108f34b4f SignalHandler(int) + 287
3 libsystem_platform.dylib 0x00007fff919e252a _sigtramp + 26
4 swift 0x0000000108d5f78b llvm::FoldingSet<llvm::AttributeSetNode>::NodeEquals(llvm::FoldingSetImpl::Node*, llvm::FoldingSetNodeID const&, unsigned int, llvm::FoldingSetNodeID&) const + 59
5 swift 0x000000010835e15f llvm::CallInst::Create(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&, llvm::Instruction*) + 367
6 swift 0x000000010835e2f0 llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >::CreateCall(llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&) + 64
7 swift 0x0000000106d869c5 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 1829
8 swift 0x0000000106d1a0dd swift::irgen::IRGenModuleDispatcher::emitGlobalTopLevel() + 861
9 swift 0x0000000106da5a5e performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1278
10 swift 0x0000000106da5f06 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 70
11 swift 0x0000000106c89a1c performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 15004
12 swift 0x0000000106c8541d frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2781
13 swift 0x0000000106c80e3c main + 1932
14 libdyld.dylib 0x00007fff91af25ad start + 1
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/keta/Documents/Swift/AgeInlineRowSample/AgeInlineRowSample/ViewController.swift /Users/keta/Documents/Swift/AgeInlineRowSample/AgeInlineRowSample/AppDelegate.swift -primary-file /Users/keta/Documents/Swift/AgeInlineRowSample/AgeInlineRowSample/AgeRow.swift -target x86_64-apple-ios9.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -I /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Products/Debug-iphonesimulator -F /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Products/Debug-iphonesimulator -F /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Products/Debug-iphonesimulator/Eureka -enable-testing -g -module-cache-path /Users/keta/Library/Developer/Xcode/DerivedData/ModuleCache -D COCOAPODS -serialize-debugging-options -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/AgeInlineRowSample-generated-files.hmap -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/AgeInlineRowSample-own-target-headers.hmap -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/AgeInlineRowSample-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/AgeInlineRowSample-project-headers.hmap -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/DerivedSources/x86_64 -Xcc -I/Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DCOCOAPODS=1 -Xcc -working-directory/Users/keta/Documents/Swift/AgeInlineRowSample -emit-module-doc-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow~partial.swiftdoc -Onone -module-name AgeInlineRowSample -emit-module-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow~partial.swiftmodule -serialize-diagnostics-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow.dia -emit-dependencies-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow.d -emit-reference-dependencies-path /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow.swiftdeps -o /Users/keta/Library/Developer/Xcode/DerivedData/AgeInlineRowSample-dpkftrsqyflgpvchqnoeoylaylrj/Build/Intermediates/AgeInlineRowSample.build/Debug-iphonesimulator/AgeInlineRowSample.build/Objects-normal/x86_64/AgeRow.o
附言:我想做一个自定义的内联行,它有UIPickerView
和两个组件。
我在实现DateInlineRow时遇到了这个问题。swift编译器似乎无法推断某些类型。
我最终使DateInlineRow
成为泛型,尽管我不需要DateInlineRow的泛型类型。
查看DateInlineRow实现
/// A row with an NSDate as value where the user can select a date from an inline picker view.
public final class DateInlineRow_<T>: _DateInlineRow, RowType, InlineRowType {
required public init(tag: String?) {
super.init(tag: tag)
onExpandInlineRow { cell, row, _ in
let color = cell.detailTextLabel?.textColor
row.onCollapseInlineRow { cell, _, _ in
cell.detailTextLabel?.textColor = color
}
cell.detailTextLabel?.textColor = cell.tintColor
}
}
public override func customDidSelect() {
super.customDidSelect()
if !isDisabled {
toggleInlineRow()
}
}
}
public typealias DateInlineRow = DateInlineRow_<NSDate>
根据这一点,您的实施应该是……
public final class AgeInlineRow_<T>: _AgeInlineRow, RowType, InlineRowType {
.....
}
public typealias AgeInlineRow = AgeInlineRow_<String>
希望它能帮助