"Command SwiftCompile failed with a nonzero exit code" error by [Product] - [Archive]

The app in question was recently distributed on September 4,2024. This time, there have been some minor improvements.

To test new version on my iPhone, compiling is done completely. But when I archive it for distribution, I get the following error.

While running pass #985712 SILFunctionTransform "DeadArgSignatureOpt" on SILFunction "@$s15Petty_treasurer12PhotosViewerC8onReturnyyF". for 'onReturn()' (at /Users/ymdakr/MyAppli/Petty_accountant/Petty_accountant/PhotosViewer.swift:173:11) Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var LLVM_SYMBOLIZER_PATH to point to it): 0 swift-frontend 0x0000000107a5b0fc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 swift-frontend 0x0000000107a59350 llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x0000000107a5b6c8 SignalHandler(int) + 292 3 libsystem_platform.dylib 0x000000018deae584 _sigtramp + 56 4 swift-frontend 0x0000000103cb3c54 swift::AbstractFunctionDecl::isDistributedTargetInvocationResultHandlerOnReturn() const + 356 5 swift-frontend 0x0000000103cb3c54 swift::AbstractFunctionDecl::isDistributedTargetInvocationResultHandlerOnReturn() const + 356 6 swift-frontend 0x000000010305cc74 canSpecializeFunction(swift::SILFunction*, swift::CallerAnalysis::FunctionInfo const*, bool) + 444 7 swift-frontend 0x000000010305c2e4 (anonymous namespace)::FunctionSignatureOpts::run() + 212 8 swift-frontend 0x0000000103247554 swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) + 3448 9 swift-frontend 0x0000000103240d74 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 252 10 swift-frontend 0x000000010327d084 swift::SimpleRequest (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 56 11 swift-frontend 0x00000001032609e8 swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) + 412 12 swift-frontend 0x00000001032636c4 swift::runSILOptimizationPasses(swift::SILModule&) + 440 13 swift-frontend 0x00000001027db3f8 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 1160 14 swift-frontend 0x0000000102405d68 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr>, llvm::PointerUnion, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1376 15 swift-frontend 0x00000001024056e4 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2888 16 swift-frontend 0x0000000102408228 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1680 17 swift-frontend 0x0000000102406f58 swift::performFrontend(llvm::ArrayRef, char const*, void*, swift::FrontendObserver*) + 3572 18 swift-frontend 0x000000010238e01c swift::mainEntry(int, char const**) + 3680 19 dyld 0x000000018daf3154 start + 2476 Command SwiftCompile failed with a nonzero exit code

Previously distributed version is also giving the same error.

Development environment: Xcode 16, macOS Sonoma 14.6.1 Run-time configuration: iOS 18

The information here is indicative of a crash in the Swift complier. That should never happen, so the first thing you should do is file a bug report with as much information as possible, ideally including a small reduced example of your project that reproduces this error for our teams to look at. Once you file that bug report, please post the FB number here for posterity.

This log has some hints for you that can help you find a workaround. Take a look at this:

While running pass #985712 SILFunctionTransform "DeadArgSignatureOpt" 
on SILFunction "@$s15Petty_treasurer12PhotosViewerC8onReturnyyF". 
for 'onReturn()' (at PhotosViewer.swift:173:1

DeadArgSignatureOpt is a hint that the complier's crash happened while it was running an optimization to remove dead arguments as functions are specialized. And you have the file path, line number, and method onReturn as further clues. What's your code doing on that line? (And all of this is valuable info to add to your bug report!) Try rewriting that code a little bit to achieve the same goal, but the exercise of doing so may help you find a different way to write it that doesn't trip up the compiler in this way.

— Ed Ford,  DTS Engineer

Program including onReturn() is below.

class PhotosViewer: UIViewController {

override func viewDidLoad() {
    
    super.viewDidLoad()
    // ダウン対策
    if newImageDT.count <= page || page < 0 {
        page = newImageDT.count - 1
    }

    initImageView(image1: newImageDT[page])

    if newImageDT.count - 1 > page {
        let rightButton = UIBarButtonItem(title: "button_next".localized, style: UIBarButtonItem.Style.plain, target: self, action: #selector(onNext))
        self.navigationItem.rightBarButtonItem = rightButton
    } else {
        let rightButton = UIBarButtonItem(title: "".localized, style: UIBarButtonItem.Style.plain, target: self, action: #selector(onNext))
        self.navigationItem.rightBarButtonItem = rightButton
    }
    let leftButton = UIBarButtonItem(title: "menu_Return".localized, style: UIBarButtonItem.Style.plain, target: self, action: #selector(onReturn))
    self.navigationItem.leftBarButtonItem = leftButton

    self.navigationItem.title = shotDates[page]
    let cDateTime = cm.datestring(targetDate: Date(), format: "yyyy-MM-dd HH:mm:ss")
    let parm = "checkAt=cast(\"" + cDateTime + "\" as datetime), checkBy=\"" + accountantName + "\" WHERE id = \"" + contract.contID + "\" AND  file_name = \"" + fileNames[page] + "\" AND  checkBy = \"\""
    // 画像確認記録を登録
    let currentPage = page
    db.updateImage(fileName: fileNames[currentPage], parm: parm) { [self] completion in
        if completion == 0 {
            dm.updateImagerecord(fileName: fileNames[currentPage], checkAt: cDateTime, checkBy: accountantName) // 内部データも更新
        }
    }

    let pinchGesture = UIPinchGestureRecognizer()
    pinchGesture.addTarget(self, action: #selector(pinchAction(_:) ) )
    view.addGestureRecognizer(pinchGesture)

    let rotateGesture = UIRotationGestureRecognizer()
    rotateGesture.addTarget(self, action: #selector(rotateAction(_:) ) )
    view.addGestureRecognizer(rotateGesture)
            
    let panOrSwipe = UIPanGestureRecognizer(target: self, action: #selector(didPan(_:)))
    view.addGestureRecognizer(panOrSwipe)

    let tapGesture = UITapGestureRecognizer()
    tapGesture.addTarget(self, action: #selector(tapAction(_:)))
    view.addGestureRecognizer(tapGesture)

    let longPressGesture = UILongPressGestureRecognizer()
    longPressGesture.addTarget(self, action: #selector(longPressAction(_:)))
    view.addGestureRecognizer(longPressGesture)
    
}

〜 〜 〜

@objc func onReturn() {
    page -= 1
    if page > 0 {
        self.loadView()
        self.viewDidLoad()
        return
    } else {

self.navigationController?.popViewController(animated: true) return } }

〜 〜 〜

}

onReturn() is in Line 173.

This file displays images. onReturn() returns the image to the previous one, or returns to the screen it was called from if all images have been returned.

I do not know what is the FB number.

Suddenly, the problem was solved.

What I did was simple, I just changed the function name as follows:

onReturn() -> toReverse()

I don't know the cause, but since the previous reply said the following, I tried the simplest thing to do, which is to change the name, and the problem was solved. Thank you.

"Try rewriting that code a little bit to achieve the same goal"

"Command SwiftCompile failed with a nonzero exit code" error by [Product] - [Archive]
 
 
Q