Command SwiftCompile failed with a nonzero exit code. in xocde 16 and 15 where as it was working fine in xcode 14.3

My project’s source code was building, running, and archiving successfully in Xcode 14.3. However, after upgrading to Xcode 15, I began encountering the error: “Command SwiftCompile failed with a nonzero exit code.”

I couldn't resolve the issue, so I decided to continue using Xcode 14.3. Recently, I upgraded to macOS Sequoia and also updated to Xcode 16. Unfortunately, the same error persists in the latest Xcode: “Command SwiftCompile failed with a nonzero exit code.”

The unfortunate part is that Xcode 14.3 no longer works after the macOS upgrade. Whenever I try to run the code, I get the following popup.

Answered by DTS Engineer in 805323022

OK, well, that’s definitely the compiler crashing )-:

I can’t offer any meaningful input as to why it’s crashing. To start, the crash report has been mushed completely by the forums. When you post a crash report, it’s best to do as as a text attachment, which improves its chances of making it through intact. See Posting a Crash Report for advice on that.

However, I usually can’t do much with a compiler crash report anyway. That’s not a codebase I’m particularly familiar with.

Still, it’s safe to say that the compiler shouldn’t crash, so any crash like this is bugworthy. The question is how best to file an actionable bug report. My general advice on that front is that you try cutting down your project to isolate the section of code that’s causing the crash. That has two benefits:

  • Once you have a small test project that demonstrates the crash, you can file a bug with that. That way you don’t have to share your entire project with Apple.

  • As you cut code out of the project, at some point things will stop crashing. That might allow you to come up with a workaround.

Once you file your bug, please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I have some general advice about these sorts of errors in Command [something] failed with a nonzero exit code. In the case of SwiftCompile build step, that usually means that the Swift compiler has crashed O-: Needless to say, that’s not good.

The unfortunate part is that Xcode 14.3 no longer works after the macOS upgrade.

Yep. I hate to be the bearer of bad news, but you really should’ve dealt with this about a year ago. It’s fine to revert to the older version of Xcode to get around an immediate issue, but that’s only a short-term workaround. In the medium term you need to solve the problem properly.

Right now I see two options:

  • You can temporarily re-install macOS 14, which will allow you to run Xcode 14 again, which will get you up and building.

  • But, as a matter of a priority, you need to work out why Xcode 16 is failing.

Apropos that last point, please:

  1. Use the technique described in the above-mentioned post to get the transcript of the failed build step.

  2. Post that here as a text attachment.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for the suggestion,


Translated Report (Full Report Below)

Process: swift-frontend [60506] Path: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend Identifier: swift-frontend Version: ??? Code Type: X86-64 (Native) Parent Process: XCBBuildService [49159] Responsible: Xcode [49137] User ID: 501

Date/Time: 2024-09-23 22:56:53.9089 +0530 OS Version: macOS 15.0 (24A335) Report Version: 12 Bridge OS Version: 9.0 (22P353) Anonymous UUID: 52618F1C-E345-3852-19A2-6792AF2BDC3C

Sleep/Wake UUID: 9CCC2F71-394E-44C1-B77F-EAC4AE296FD2

Time Awake Since Boot: 120000 seconds Time Since Wake: 3706 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: UNKNOWN_0xD at 0x0000000000000000 Exception Codes: 0x000000000000000d, 0x0000000000000000

Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11 Terminating Process: exc handler [60506]

VM Region Info: 0 is not in any region. Bytes before following region: 4415254528 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START --->
__TEXT 1072b7000-10ec10000 [121.3M] r-x/r-x SM=COW /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend

Kernel Triage: VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter VM - (arg = 0x3) mach_vm_allocate_kernel failed within call to vm_map_enter

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 swift-frontend 0x1078bfd71 llvm::TinyPtrVector<swift::ModuleDecl*>::push_back(swift::ModuleDecl*) + 129 1 swift-frontend 0x1089f00bc swift::constraints::ConstraintGraph::computeConnectedComponents(llvm::ArrayRef<swift::TypeVariableType*>) + 2876 2 swift-frontend 0x108956908 swift::constraints::SplitterStep::take(bool) + 216 3 swift-frontend 0x10894885e swift::constraints::ConstraintSystem::solveImpl(llvm::SmallVectorImpl<swift::constraints::Solution>&) + 606 4 swift-frontend 0x10894c204 swift::constraints::ConstraintSystem::solve(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 52 5 swift-frontend 0x10894b26f swift::constraints::ConstraintSystem::solve(swift::constraints::SyntacticElementTarget&, swift::FreeTypeVariableBinding) + 1119 6 swift-frontend 0x108b74532 swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 642 7 swift-frontend 0x108b7417f swift::TypeChecker::typeCheckExpression(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 431 8 swift-frontend 0x108c7a9cd (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 413 9 swift-frontend 0x108c8032c swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 252 10 swift-frontend 0x108c7dc1a bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 314 11 swift-frontend 0x108c80795 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 1381 12 swift-frontend 0x108c800fa bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 314 13 swift-frontend 0x108c7a8a9 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 121 14 swift-frontend 0x108c8032c swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 252 15 swift-frontend 0x108c7dc1a bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 314 16 swift-frontend 0x108c7c4ae swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 1646 17 swift-frontend 0x1091ba80d swift::TypeCheckFunctionBodyRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()>(swift::TypeCheckFunctionBodyRequest const&, swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType)::'lambda'()) + 781 18 swift-frontend 0x10911fec7 swift::AbstractFunctionDecl::getTypecheckedBody() const + 151 19 swift-frontend 0x108cd4109 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 969 20 swift-frontend 0x108cdbe44 swift::TypeCheckSourceFileRequest::OutputType swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()>(swift::TypeCheckSourceFileRequest const&, swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType)::'lambda'()) + 772 21 swift-frontend 0x108cd3d21 swift::performTypeChecking(swift::SourceFile&) + 337 22 swift-frontend 0x107a43069 swift::CompilerInstance::performSema() + 281 23 swift-frontend 0x107619f86 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 918 24 swift-frontend 0x107618d58 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4392 25 swift-frontend 0x10758b6a7 swift::mainEntry(int, char const**) + 8103 26 dyld 0x7ff80c41c2cd start + 1805

OK, well, that’s definitely the compiler crashing )-:

I can’t offer any meaningful input as to why it’s crashing. To start, the crash report has been mushed completely by the forums. When you post a crash report, it’s best to do as as a text attachment, which improves its chances of making it through intact. See Posting a Crash Report for advice on that.

However, I usually can’t do much with a compiler crash report anyway. That’s not a codebase I’m particularly familiar with.

Still, it’s safe to say that the compiler shouldn’t crash, so any crash like this is bugworthy. The question is how best to file an actionable bug report. My general advice on that front is that you try cutting down your project to isolate the section of code that’s causing the crash. That has two benefits:

  • Once you have a small test project that demonstrates the crash, you can file a bug with that. That way you don’t have to share your entire project with Apple.

  • As you cut code out of the project, at some point things will stop crashing. That might allow you to come up with a workaround.

Once you file your bug, please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Okay Thanks for your help really appreciated

Just for an update,

After so many builds failed I finally got success.

How do I resolve it?

  • I removed all Swift file (storyboard and xib are fine)
  • Build fine means a problem in Swift file
  • Added one by one swift till error is not come, (started from utilities, model, singleton, database, ViewModel, Custom View, View)
  • In one of file in my switch case
var text = "en" (or any other language code)
switch stringObject {
case "ABC": break
case "QPR": break
case "translate \(text)":
//From Xcode 16 and 15 swift compiler are file to process this case whereas older was working fine
default:
break
}

It’s hard to offer advice without knowing more about the context of that code. Two things:

  • What’s the type of stringObject?

  • In your translate case, there are no statements, so the code is never going to compile. If I add a break, the code compiles for me. In your main project, if you replace that code with a break, does the compiler still crash?

Alternatively, can you share a tiny test project, with just that code, that demonstrates the compiler crash?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I can't share full code file or project, but here is case.

I had setting file in that it calls API and in response callback I have DispatchQueue.main.async block to update UI.

In response I am receving on "serverLangValue" .

If you copy and check following code with any project, you will get

Command SwiftCompile failed with exit code (since this small pics of code it show file name but in atual profject it's not pointing file) . After commenting "case "translate (text)": " It will work fine

            let serverLangValue = ""// Server return value
            let switchEnum = "translate \(serverLangValue)"
            let text = "en" //(or any other language code)
            switch switchEnum {
            case "ABC": break
            case "QPR": break
            case "translate \(text)": break
                //From Xcode 16 and 15 swift compiler are file to process this case whereas older was working fine
            default:
                break
            }
        }
If you copy and check following code with any project, you will get

There is something else going on here. Here’s what I did:

  1. Using Xcode 16.0 on macOS 14.7, I created a new project from the iOS > App template.

  2. I added a file to that called Test.swift.

  3. In that, I added your code, wrapped in a test() function. See below for the exact contents of that file.

  4. I chose Product > Build and it built just fine.

Please run through those exact steps and let me know what you see.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"


func test() {
    let serverLangValue = ""// Server return value
    let switchEnum = "translate \(serverLangValue)"
    let text = "en" //(or any other language code)
    switch switchEnum {
    case "ABC": break
    case "QPR": break
    case "translate \(text)": break
        //From Xcode 16 and 15 swift compiler are file to process this case whereas older was working fine
    default:
        break
    }
}

Can you try following code

       DispatchQueue.main.async {
            let serverLangValue = ""// Server return value
                       let switchEnum = "translate \(serverLangValue)"
                       let text = "en" //(or any other language code)
                       switch switchEnum {
                       case "ABC": break
                       case "QPR": break
                       case "translate \(text)": break
                           //From Xcode 16 and 15 swift compiler are file to process this case whereas older was working fine
                       default:
                           break
                       }
                   }
        }
}

That snippet doesn’t crash the compiler for me either.

IMPORTANT I tested this snippet using the same process that I tested your previous snippet. I suspect that the crash you’re seeing is not caused by the code itself but rather by the context in which you’re compiling it. I recommend that you take your snippet and put it into a test project, just like I’ve described above. I suspect it’ll work in that context for you, just like it does for me.

Once you have a crashing and a working case, you can start removing code from the former and adding code to the latter to isolate what’s actually triggering the crash.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Command SwiftCompile failed with a nonzero exit code. in xocde 16 and 15 where as it was working fine in xcode 14.3
 
 
Q