Command failed due to signal: Segmentation fault: 11 after upgrade to Xcode 8 and Swift 3
For teamItem.toDictionary
, try putting teamItem.toDictionary as Any
.
Command failed due to signal: Segmentation fault: 11 after using generics in graph classes - swift3
Can't tell you why your code is crashing. You'd better send a bug report for this issue. But I have a workaround for you:
public protocol VertexType: Hashable {
associatedtype DataType
var data: DataType { get set }
}
public class Vertex<T: Hashable>: VertexType {
public var data: T
required public init(data: T) {
self.data = data
}
}
extension Vertex {
public var hashValue: Int {
return "\(data)".hashValue
}
static public func ==(lhs: Vertex, rhs: Vertex) -> Bool {
return lhs.data == rhs.data
}
}
extension Vertex: CustomStringConvertible {
public var description: String {
return "\(data)"
}
}
// MARK: - Edge
public class Edge<V: VertexType> {
public var source: V
public var destination: V
public let weight: Double?
required public init(source: V, destination: V, weight: Double? = nil) {
self.source = source
self.destination = destination
self.weight = weight
}
}
extension Edge: Hashable {
public var hashValue: Int {
return "\(source)\(destination)\(weight)".hashValue
}
// We need to overload the equals operator because Hashable implements Equatable
static public func ==(lhs: Edge<V>, rhs: Edge<V>) -> Bool {
return lhs.source == rhs.source && lhs.destination == rhs.destination && lhs.weight == rhs.weight
}
}
And now you can use Vertex
subclasses as you wanted:
public class IntVertex: Vertex<Int> {}
Edge(source: IntVertex(data: 1), destination: IntVertex(data: 2))
UPDATE:
Looks like this was fixed in Swift 3.1. At least similar bug not crashing Xcode 8.3 anymore. So probably it will be enough to update your Xcode.
Xcode 7.2 : Command failed due to signal: Segmentation fault: 11
The error occurs in this line
let nameOfSensor = (name: values[0])
which is just meaningless syntax. it's
let nameOfSensor = values[0]
But you can simplify the repeat loop
for column in columns {
let values = column.componentsSeparatedByString(columnDelimiter)
if let nameOfSensor = values.first {
nameOfSensors?.append(nameOfSensor)
}
}
It checks also if the separated array contains a first item at all.
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 :)
Related Topics
Closure:Use Unresolved Identifier 'Self'
Xcframework Issue, a Library with the Identifier "Ios-Armv7_Arm64" Already Exists
Rotate a Text View and Its Frame in Swiftui
Metal Kernels Not Behaving Properly on the New MACbook Pro (Late 2016) Gpus
Video Upload to Amazon S3 in Swift
Swiftui - Unwrap Optional Image Data to Create Image Based on Uiimage(Data)
Loading Multiple Google Interstitial Ads Makes App Crash
Swift Unit Testing with Xctassertthrows Analogue
Counting Coloured Pixels on the Gpu - Theory
Create a Navigationlink Without Back Button Swiftui
Using Decodable with Inheritance Raises an Exception
How to Apply a Grace Time Using Rx
How to Set Avaudioengine Input and Output Devices (Swift/Macos)