Swift compiler error: segmentation fault: 11 on Archive

Swift compiler error: segmentation fault: 11 on Archive

在提交 App Store 发布之前存档我的 iOS 应用程序时,我收到一条错误消息

Command failed due to signal: Segmentation fault: 11

然后是一大堆路径等等,最后提到了我在应用程序中拥有的一个功能。这是函数:

func matrixOperationRequiresScalar(operation: MatrixOperation) -> Bool {
    switch operation {
    case .Addition, .Subtraction, .Multiplication, .Division, .Negative, .Determinant, .Inverse, .Transpose, .EigenOps: return false
    case .ScalarMultiplication, .ScalarDivision, .Power: return true
    }
}

你可以看出 operation 是一个枚举,这里涵盖了所有情况。

我该怎么做才能解决这个问题?

您代码中的开关缺少 swfit 所需的默认大小写。您可以轻松更正此问题:

func matrixOperationRequiresScalar(operation: MatrixOperation) -> Bool {
    switch operation {
    case .Addition, .Subtraction, .Multiplication, .Division, .Negative, .Determinant, .Inverse, .Transpose, .EigenOps: return false
    case .ScalarMultiplication, .ScalarDivision, .Power: return true
    default: return true
    }
}

Source