分段故障:11 - Xcode 6.3

时间:2015-06-26 15:41:33

标签: ios xcode swift compiler-errors xcode6.3.2

无法存档

我的应用程序在模拟器和多个设备上运行正常(Xcode 6.3.2,基于swift)。但是当我尝试存档时,我收到错误Command failed due to signal: Segmentation fault: 11

其他人面临同样的问题

Segmentation Fault 11 when running Swift app

"Command failed due to signal: Segmentation fault: 11" - What is the issue?

Command failed due to signal: Segmentation fault: 11

根本原因?

但似乎每个人都有不同的理由来获取错误..我无法理解我得到的错误消息。发布如下,任何提示或提示将不胜感激!

错误日志

0  swift                    0x0000000108e5d2b8 llvm::sys::PrintStackTrace(__sFILE*) + 40
1  swift                    0x0000000108e5d794 SignalHandler(int) + 452
2  libsystem_platform.dylib 0x00007fff8897bf1a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fff574b7b28 _sigtramp + 3467885608
4  swift                    0x0000000108a053f2 swift::serialization::Serializer::writeCrossReference(swift::Decl const*) + 578
5  swift                    0x0000000108a0e275 swift::serialization::Serializer::writeAllDeclsAndTypes() + 2181
6  swift                    0x0000000108a0f2f8 swift::serialization::Serializer::writeAST(llvm::PointerUnion<swift::Module*, swift::SourceFile*>) + 2600
7  swift                    0x0000000108a11960 swift::serialization::Serializer::writeToStream(llvm::raw_ostream&, llvm::PointerUnion<swift::Module*, swift::SourceFile*>, swift::SILModule const*, swift::SerializationOptions const&) + 144
8  swift                    0x0000000108a12521 swift::serialize(llvm::PointerUnion<swift::Module*, swift::SourceFile*>, swift::SerializationOptions const&, swift::SILModule const*) + 321
9  swift                    0x0000000108746c1a frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 5514
10 swift                    0x00000001087454e6 main + 1814
11 libdyld.dylib            0x00007fff8db235c9 start + 1
12 libdyld.dylib            0x0000000000000080 start + 1917700792

2 个答案:

答案 0 :(得分:3)

解决了它。问题是两件事: 1)转换为Double 2)处理空数组

转换为双重

var lat: Double? = d["lat"].doubleValue更改为var lat: Double? = Double(d["lat"].doubleValue)

处理空数组

更改
let brands = d["brands_unfiltered"].arrayValue {
if brands == [] {
    // Do nothing (empty)
}
else{
    // Do stuff
}

if let brands = d["brands_unfiltered"].arrayValue as Array! {
     // Do stuff
}

要查找根本原因,我停用了大部分代码,直到找到了归档不起作用的内容。此后,解决方案非常简单。希望这有助于其他人在遇到同样的错误。

答案 1 :(得分:0)

我发现导致“归档”操作失败的代码出现此错误“命令因信号失败:分段错误:11”

当我在cellForRowAtIndexPath函数中使用indexPath时,我需要添加一个感叹号(即indexPath!而不是indexPath)。但是,如果我省略感叹号,我仍然会为什么会出现这样的错误感到困惑。有谁知道原因?

    override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell! {

            // code to get cell, etc

            let thumbnailImage = self.userPhotos?.getFromCacheOrDownload(username,
                circle: team.circle(), delegate: self, indexPath: indexPath!)
            cell.userPhotoImageView.image = thumbnailImage

            return cell
}
相关问题