【发布时间】:2014-06-11 03:26:27
【问题描述】:
我的代码中出现了这个编译器错误,我不知道为什么:
<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
}
(我有更多非常相似的案例,为了简单起见,我将它们排除在外 - 错误不在其中)
第一个错误
一行中有一个错误: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 中的一个错误?另请注意,当一次注释掉两个错误时,错误消息是相同的。
【问题讨论】:
-
请提交错误报告here!
标签: ios xcode swift ios8 xcode6