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
Get HTML from Wkwebview in Swift
Accessing Code in Swift 3 Error
Why Is Swift Compile Time So Slow
How to Create a Global Variable
What Is a Good Example to Differentiate Between Fileprivate and Private in Swift3
Custom Back Button For Navigationview'S Navigation Bar in Swiftui
How to Round a Double to the Nearest Int in Swift
Strange Swift Numbers Type Casting
How to Make a Weak Protocol Reference in 'Pure' Swift (Without @Objc)
Opt Out of Uiscenedelegate/Swiftui on Ios
Changing the Status Bar Color For Specific Viewcontrollers Using Swift in Ios8
Cfrunloop in Swift Command Line Program
How to Convert Unix Epoch Time to Date and Time in iOS Swift
Swift 4 Decodable - Dictionary With Enum as Key