Xcode error: Abort Trap 6

Occasionally, I get this error and I tried to research it but I couldnt figure out how to solve it. It says:


1. While deserializing SIL vtable for 'PostTextCVC' in module 'Appp'
error: Abort trap: 6

The only way to dismiss this is to user another simulator or my actual phone. I don't know how to fix it for real though, don't even know what that error means. It's not exactly descriptive. Any suggestions?


PS: Xcode version 10.0. beta 5

@Max - thanks, that solved my issue too.

I had "guard let path = path else { return }" , which when changed to "guard let goodPath = path else { return }" solved the problem.

Strange, as there are loads of examples online/tutorials/books that use that form, but for some reason Swift doesn't like it.

(Xcode 12.5.1, Swift 5)

Remove all swift files from target.

Check target's build phases > compile source's count is zero

add files little by little to target

build and check to success

starting with the fewest dependencies. likes to entity, enums, views.. to VC

I solved the problem this way.

Like @Max suggested, it definitely happens around guard utilizing the same outer scope var name for the local scope. It's incredibly difficult to reproduce though. I've ran into this a few times now, and it's always around refactor changes, specifically variable name changes around these scopes. It feels as if precompiled/cached/magic fails to recognize the change and then is unable to bust the cache. The stack trace seems to drop you off somewhat near recent changes that have been done, but doesn't give you any other hints. Compiler isn't going to give you any hints either, sounds like a brute force trial and error where you start looking for your wallet in the microwave, or debugging purely off superstition. So thanks and sorry to ya'll who were able to track this down.

Same issue here. After trying everyone's suggestions from this thread and coming up dry, I finally narrowed down the needle-in-a-haystack.

In my case it was a Swift Package. Debug builds built fine, but Release builds (with optimizations) caused the Swift compiler to crash with the same stack trace and error: Abort trap: 6 as others have mentioned.

The culprit? A single missing import statement in one of the package's .swift files.

To elaborate the particulars:

  • PackageA (crashed compiler) has PackageB as a dependency, which in turn has PackageC as a dependency.
  • All three packages show up in the dependency pool of course.
  • PackageA was accessing methods from PackageC without actually using an import PackageC statement (possibly by way of PackageB exporting types from PackageC in some of its interfaces).
  • The missing import statement was forgotten because compilation succeeded in Debug builds and development and testing was only ever done in a Debug build. It wasn't until production Release builds of an application that imported PackageA that the compiler crash mysteriously cropped up with very little context.

My problem was with the line:

return ()

i removed the line and problem fixed!

Just to add my experience for anyone finding this thread later – I had a similar non-descriptive "abort trap" error when compiling my own project. In my case, I'd added a possible call to fatalError() in one of my classes' initializers during an experiment – it looks like that was enough to bring it about. Removing that branch was enough to get back to where I was before the error ever showed up.

In my case, I solved it by changing guard else return to if let block of code in for-loop, and this for-loop is in network callback. In brief, I think the compiler doesn't know where to execute from it hit return in guard else. Hope it helps

Encountered this compiler crash when a guard case is followed by a let (FB9643656). E.g.:

let value = CollectionDifference.Change.insert(offset: 1, element: 1, associatedWith: nil)

guard case .insert(_, _, let associatedWith) = value, let associatedWith = associatedWith else { 
    return
}

But splitting the two guarded conditions into separate guard statements solves the issue.

Just encountered this problem.

caused by a guard let unwrapping with the same name as a previous value in the same block, the compiler didn't identify the error.

example :

{
 var mData : String? = Storage.value(key: "mValue")
 guard let mData = mData else {return}
}

Hey, everyone!

I've been trying to fix this issue for months without any success, it just popped up after the new version of xcode was released and I was kinda hopeless.

Fortunately, I've found a workaroud, it goes like this:

  • Choose you target
  • Build settings
  • Optimization Level
  • Debug
  • Optimize for size [-Osize]

It's been working well enough, but it was annoying that I couldn't look up any local variables in build time while debugging. Well, today I finally found the issue and managed to fix it. The code looked like that:

switch item {
case .a(var model), .b(var model), .c(var model):
// cell dequeue here
// model mutation here
// cell configuration here from model
// cell return here
}

The problem of that, I suppose, that we're fetching the mutable models from different cases and mutate them after that (by the way, all models are of the same struct, of course, it is legal to do so). I've changed it like that:

switch item {
case .a(let model), .b(let model), .c(let model):
// cell dequeue here
var configurationModel = model
// configurationModel mutation here
// cell configuration here from configurationModel
// cell return here
}

Hope it could be useful for someone who encountered such unusual behaviour of xcode.

got the same in Xcode 13.2.1 with swiftui I have 3 nested ForEach's. Had to break them up into separate functions for each nested ForEach level

Hey, everyone! I found the solution for this problem, hope it could be useful

  • Select Pods > Build Settings > Swift Compiler - Code Genration > Optimization Level > Debug and Realease make "No Optimization [-Onone]"
  • Select Your Project > Select Targets > Build Settings > Swift Compiler - Code Genration > Optimization Level > Debug and Realease make "No Optimization [-Onone]"

Thank you from VN!

Same issue here. It doesn't happen when building in the simulator. It happens when I am trying to archive the build.

I'm able to reliably reproduce this with the code below. If I comment it out, the Abort trap disappears.

extension DocumentGroup {
  func useDefaultSizeIfAvailable() -> some Scene {
    if #available(macOS 13.0, *) {
      return self.defaultSize(.init(width: 750, height: 750))
    } else {
      return self.windowStyle(.automatic)
    }
  }
}
Xcode error: Abort Trap 6
 
 
Q