ios - 由于信号 : Segmentation fault: 11 when Compiling Swift Project,命令失败

标签 ios xcode swift

compiler crash

我想在 iOS 中制作一个俄罗斯方 block 游戏项目。但我在这张照片中遇到了这个问题。 Xcode 出现这个错误,我无法修复它。我曾经认为,一个Shape类有7个不同的Shape子类,我将它们分成8个包含Shape类的文件,可能会出现这个错误。然后我把它们全部放在一个文件中。然而,它再次发生。

这是我的一些代码:

class Shape: Hashable, CustomStringConvertible{
    let color: BlockColor

    var blocks = Array<Block>()
    var orientation: Orientation
    var column: Int = 0
    var row: Int = 0

    // 每个块中的每个小块的位置
    var blockColRowPositions: [Orientation: Array<(col: Int, row: Int)>]{
        return [:]
    }
    // 每个块在底部的形状
    var bottomBlocksForOrientations: [Orientation: Array<Block>]{
        return [:]
    }


    var bottomBlock: Array<Block>{
        guard let bottomBlocks = bottomBlocksForOrientations[orientation] else{
            return []
        }
        return bottomBlocks
    }

    var hashValue:Int{
        return blocks.reduce(0) {$0.hashValue ^ $1.hashValue}
    }

    var description:String{
        return "\(color) block facing \(orientation) : \(blocks[firstIndex]), \(blocks[secondIndex]), \(blocks[thirdIndex]), \(blocks[forthIndex])"
    }

// ....

}


class O_Shape: Shape {

    // 每个块中的每个小块的位置
    override var blockColRowPositions: [Orientation: Array<(column: Int, row: Int)>] {
        return [
            Orientation.zero:       [(0,0),(1,0),(0,1),(1,1)],
            Orientation.twoQuater:  [(0,0),(1,0),(0,1),(1,1)],
            Orientation.fourQuater: [(0,0),(1,0),(0,1),(1,1)],
            Orientation.sixQuater:  [(0,0),(1,0),(0,1),(1,1)]
        ]
    }

    override var bottomBlocksForOrientations: [Orientation: Array<Block>] {
        return[
            Orientation.zero:       [blocks[thirdIndex], blocks[forthIndex]],
            Orientation.twoQuater:  [blocks[thirdIndex], blocks[forthIndex]],
            Orientation.fourQuater: [blocks[thirdIndex], blocks[forthIndex]],
            Orientation.sixQuater:  [blocks[thirdIndex], blocks[forthIndex]]
        ]
    }

}

最佳答案

图片显示编译过程中崩溃了。这曾经在 Swift 中相当常见,但现在已经很少见了。

您应该做的第一件事是确保您使用的是最新版本的 Xcode,即 7.2.1。

如果编译崩溃仍然发生,您也许可以通过找出导致崩溃的代码行来解决问题。我曾经通过注释掉整个文件然后逐一取消注释来做到这一点,直到它导致崩溃。

那么你需要找到一种重写代码的方法以避免崩溃,并且你还需要向 Apple @ https://bugreport.apple.com 发送错误报告。 。无论您向其抛出什么代码,编译器都不应该崩溃,如果您的代码错误,它应该产生错误消息。

关于ios - 由于信号 : Segmentation fault: 11 when Compiling Swift Project,命令失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35582758/

相关文章:

ios - 使用 MBXMapkit (Mapbox) 以用户位置为中心的 map

objective-c - 分割获取的结果 Controller 中断搜索显示

iphone - 如何删除 UITabBarItem

ios - Swift 动画重复次数

xcode - iOS 6.0 AutoLayout 约束问题 : subviews disappear when rotated

ios - 从用户默认值中检索 GMSPlace 实例

swift - 在 WatchOS 和 Today Extension 小部件之间传递数据

ios - 调整 AVPlayer 大小时的自动布局问题

ios - 使用Swift进行 Realm 保存的问题。我错了,我直接从Realm Browser 0说了“删除对象”

iOS UIView 阴影在模拟器中显示不同