【问题标题】:Segmentation Fault: 11 - Xcode 6.3分段错误:11 - Xcode 6.3
【发布时间】:2015-09-13 15:31:46
【问题描述】:

无法存档

我的应用在模拟器和多个设备上运行良好(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

【问题讨论】:

  • 您是否尝试过链接到的文章中列出的任何解决方案?
  • 是的。但问题是我无法确定根本原因是什么。如果我只是新的 - 成功了一半:)

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


【解决方案1】:

解决了。问题是两件事: 1) 转换为双倍 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
}

为了找到根本原因,我停用了大部分代码,直到找到导致归档无法运行的原因。此后,解决方案非常简单。希望这可以帮助其他人遇到同样的错误。

【讨论】:

  • 非常感谢您回答自己的问题。你必须知道当一个问题没有得到解决时的感觉。对此,我感谢你。
  • 嗨 Peder,我遇到了完全相同的问题。堆栈跟踪没有进一步的线索......你怎么知道这是由于你指出的代码段造成的?
  • 在错误日志中,我注意到特定文件的编译失败。我必须查看此版本和之前版本(我使用“存档”准备的版本)之间的所有更改。这是非常乏味的。另外,我想知道为什么这样的错误只发生在“存档”期间而不是在通常的构建过程中?
  • 有没有可能:_sigtramp + 26 专门表示数组和/或双重问题?
【解决方案2】:

我找到了导致我的“存档”操作失败并出现此错误“命令因信号而失败:分段错误: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
}

【讨论】:

  • 为迟到的回复道歉 - 现在才看到这个。我不知道。我不在我的代码中使用感叹号(Xcode 7.0)。如果有 nil (避免应用程序崩溃),这当然会更安全。示例代码:覆盖 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier, forIndexPath: indexPath) as! MenuTableViewCell let menu = menuOptions[indexPath.row] cell.menuText.text = menu.name return cell }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多