5

Can't archive

My app runs fine (Xcode 6.3.2, swift based) on Simulator and on multiple devices. But when I try to archive it I get the error Command failed due to signal: Segmentation fault: 11.

Others face same problem

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

Root cause?

But it seems that each have different reasons for getting the error.. I am unable to comprehend the error message I am getting. Posted below, any hints or tips would be greatly appreciated!

Error log

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
Community
  • 1
  • 1
Peder Wessel
  • 646
  • 1
  • 9
  • 23

2 Answers2

4

Solved it. Problem was two things: 1) Converting to Double 2) Handling an empty array

Converting to Double

Changed from var lat: Double? = d["lat"].doubleValue to var lat: Double? = Double(d["lat"].doubleValue)

Handling an empty array

Changed from

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

To

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

To find the root cause I deactivated larges part of the code until I found what got the archiving not to function. Thereafter the solution was pretty straight forward. Hope this helps someone else struggling with the same error.

Peder Wessel
  • 646
  • 1
  • 9
  • 23
  • I really appreciate you answering your own question. You must know how it feels when a question is left unresolved. To that, I thank you. – abuv Sep 16 '15 at 07:41
  • hi Peder, I am hitting exactly the same problem. There is no further clue from the stack trace... how do you figure out that it is due to the code segment that you pointed out? – user3204765 Sep 25 '15 at 03:51
  • 1
    In the error log, I noticed that the compilation failed for a specific file. I had to look through all the changes between this version and previous release (which I prepared using "Archive"). This is very tedious. Also, I am wondering why such error only occur during "Archive" and not during the usual Build process? – user3204765 Sep 25 '15 at 12:01
  • is there any chance that: `_sigtramp + 26` is specifically indicating array and/or double issues? – Confused Nov 12 '19 at 03:20
0

I found the code that cause my "Archive" action to fail with this error "Command failed due to signal: Segmentation fault: 11"

When I use the indexPath in the cellForRowAtIndexPath function, I need to put an exclamation mark (i.e indexPath! instead of indexPath). However, I still puzzled by why there is such error if I omit the exclamation mark. Does anyone know the reason?

    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
}
user3204765
  • 124
  • 5
  • Apologies for late response - just saw this now. I am not sure. I do not use the exclamation marks in my code (Xcode 7.0). Which of course makes it safer in case there is nil (avoids crashing app). Example code: override 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 } – Peder Wessel Oct 04 '15 at 15:20