Swift Compiler Segmentation Fault When Building

Segmentation fault: 11 - Xcode/Swift 5 compile issue

Naming the enum associated values is a shadow zone. While it is apparently accepted under certain conditions, it is not used or even mentioned in the official Swift Language Guide chapter on Enumerations. So in this case, your code compiles fine if you remove the naming.

enum Enumeration {
case possibilityA(Protocol)
case possibilityB((Result<SomeStruct, Error>) -> ())
}
...
func method() {
let _ = Enumeration.possibilityB({ _ in
})

In any case, a crashing compiler is never nice, no matter how bad code you feed it, and furthermore you got a pretty cool minimal test, so filling a report should be your duty and honor :)

Swift Compiler Error : Command failed due to signal: Segmentation fault: 11

IMHO
the reason is that you use "self" in "button.addTarget( self, action: #selector(handleRegister), for:.touchUpInside)". To check that you could insert "nil" instead of "self". And further after you try inserting "nil", you could add "print(self)" to understand that "self" is referring not to "LoginController" as you intended.

Xcode produces Segmentation fault: 11 compiling

Update: the following variant works

struct ButtonContainer{
let label: VStack<TupleView<(Image, Text)>>
let action: ()-> Void

init(_ text: String, systemName: String, action: @escaping ()-> Void){
self.label = VStack {
Image(systemName: "\(systemName)") // << make it string literal !!!
Text(text)
}
self.action = action
}
}

Initial (just in case):

Taking into account that SwiftUI uses almost everywhere opaque types by some View, the approach with erasing type for label compiled & run well (tested with Xcode 11.3.1 / iOS 13.3). I'm not sure about your needs to have explicit type here, but just be aware.

struct ButtonContainer{
let label: AnyView
let action: ()-> Void

init(_ text: String, systemName: String, action: @escaping ()-> Void){
self.label = AnyView(VStack {
Image(systemName: systemName)
Text(text)
})
self.action = action
}
}


Related Topics



Leave a reply



Submit