我在我的代码中得到了这个编译器错误,我不知道为什么:
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: swift frontend command failed due to signal (use -v to see invocation)
Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254错误出现在以下代码段中的某处:
var animalViewToSwap: AnimalView = animalViewMatrix.objectAtRow(0, andColumn: 0) as AnimalView
var currentRow = 0
var currentColumn = 0
var animalToSwapWith = true
var currentLocation = animalViewMatrix.findLocationOfObject(animalView)
currentRow = Int(currentLocation.row) - 1
currentColumn = Int(currentLocation.column) - 1
var rowDisplacement = 0
var columnDisplacement = 0
switch inDirection{
case "left":
columnDisplacement = withDistance * -1
if (Int(animalViewMatrix.columns) > currentColumn + columnDisplacement)&&(currentColumn + columnDisplacement >= 0)&&(animalViewMatrix.objectAtRow(CInt(currentRow), andColumn: CInt(currentColumn + columnDisplacement)) is AnimalView)
{
animalToSwapWith = true;
}
else { animalToSwapWith = false }
default:
println("error")
animalToSwapWith = false
break
}(我有更多非常相似的案例,为了简单起见,我把它们省略了-- bug不在其中)
第一个错误
一个bug出现在行:animalToSwapWith = false中,如果我将它设置为true并注释掉除变量初始化行之外的所有其他错误,错误就会消失。另外,如果我注释掉了所有这些内容,但是将animalToSwapWith实例化为false,那么即使在实例化为true时也不会发生错误。
第二个错误
该行中还有第二个错误:if (Int(animalViewMatrix.columns) > currentColumn + columnDisplacement)&&(currentColumn + columnDisplacement >= 0)&&(animalViewMatrix.objectAtRow(CInt(currentRow), andColumn: CInt(currentColumn + columnDisplacement)) is AnimalView)在该行中,所有这些方法都在前面的文件中用上述相同类型的变量调用过,因此这些方法的知识应该无关紧要。
结论
发生这两个错误是有原因的,还是因为swift和Xcode-6仍处于beta测试阶段,这是Xcode中的一个bug?还要注意,在逐个注释这两个错误时,错误消息是相同的。
发布于 2014-06-19 00:44:56
这是一个Swift编译器错误,显然,测试两个或更多隐式展开的选项会导致编译器在某些/许多情况下崩溃。使用Apple's Bugreporter将此问题归档,将其标记为rdar://17212295的副本。
示例
下面是一个崩溃并出现相同错误的最小示例:
let a: String!
let b: String!
if a && b {
println("have both")
}在命令行上编译,如下所示,并见证相同的崩溃:
$ xcrun swift -v -g crash.swift发布于 2014-06-19 23:05:43
我得到了同样的错误,我追踪到:我正在扩展NSError,并且在扩展中定义了一个enum。将enum定义移出扩展已修复错误。
extension NSError {
enum WYBErrorCodes: Int {
case Fatal = 1000
case XmlParse = 1100
case CoreData = 1200
}
[...]
}发布于 2014-06-17 17:56:04
在为我的类采用NSTextViewDelegate协议时,我得到了同样的错误。如果我删除了该协议,编译就会正常进行。确实很奇怪。
https://stackoverflow.com/questions/24154163
复制相似问题