Xcode swift失败,退出代码为254 [英] Xcode swift failed with exit code 254
问题描述
我的代码中出现此编译错误,我无法弄清楚原因:
I am getting this compiler error in my code and I can't figure out why:
<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
错误显示在以下代码段中的某处:
The error is showing up somewhere in the following code segment:
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不在其中)
(I have more cases that are very similar and am leaving them out for simplicity - the bug isn't in them)
行中有一个错误: animalToSwapWith = false
如果我将其设置为true并在除变量初始化行之外的所有其余部分进行注释,则错误消失。此外,如果我将所有内容都注释掉但是将animalToSwapWith实例化为false,则会发生错误,即使它实例化为true时也不会发生错误。
One bug is in the line: animalToSwapWith = false
and if I set it to true and comment all the rest out besides the variable initialization lines the error goes away. Also if I comment all of it out but instantiate animalToSwapWith to false the error occurs even though it doesn't when it is instantiated to true.
行中有第二个错误: if(Int(animalViewMatrix.columns)> currentColumn + columnDisplacement)&&(currentColumn + columnDisplacement> = 0)&&(animalViewMatrix.objectAtRow(CInt(currentRow),andColumn:CInt(currentColumn + columnDisplacement))是AnimalView)
在这一行中,所有这些方法都在文件的前面调用过使用上述相同类型的变量,因此对方法的了解无关紧要。
There is a second error in the line:if (Int(animalViewMatrix.columns) > currentColumn + columnDisplacement)&&(currentColumn + columnDisplacement >= 0)&&(animalViewMatrix.objectAtRow(CInt(currentRow), andColumn: CInt(currentColumn + columnDisplacement)) is AnimalView)
In this line all of these methods have been called earlier in the file with variables of the same types above so knowledge of the methods shouldn't matter.
是否有这两个错误发生的原因或是因为swift和Xcode-6仍在进行beta测试,这是Xcode中的一个错误?另请注意,当一次一个地将两个错误注释掉时,错误消息是相同的。
Is there a reason why these two errors are occurring or is it because swift and Xcode-6 are still in beta testing and it is a bug in Xcode? Also note that when commenting the two errors out from each other one at a time the error message is the same.
推荐答案
这是一个Swift编译器错误,显然是对两个或多个隐式解包的选项进行测试会导致编译器在某些/多个情况下崩溃情况。使用 Apple的Bugreporter 提交此问题,将其标记为rdar:// 17212295的副本。
This is a Swift compiler bug, apparently testing for two or more implicitly unwrapped optionals causes the compiler to crash under some/many circumstances. Use Apple's Bugreporter to file this issue, mark it as duplicate of rdar://17212295.
以下是崩溃时出现同样错误的最小示例:
Here's a minimal example that crashes with the same error:
let a: String!
let b: String!
if a && b {
println("have both")
}
编译命令行如下并见证同样的崩溃:
Compile on command line as follows and witness the same crash:
$ xcrun swift -v -g crash.swift
这篇关于Xcode swift失败,退出代码为254的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!