From 2f84f516cf6b75d07166fc73e2bf35dc176f59fd Mon Sep 17 00:00:00 2001 From: stackotter Date: Mon, 20 Dec 2021 08:24:57 +1000 Subject: [PATCH] Fix crash in universal builds --- Sources/swift-bundler/Subcommands/Build.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/swift-bundler/Subcommands/Build.swift b/Sources/swift-bundler/Subcommands/Build.swift index f163eb83..8e2866a1 100644 --- a/Sources/swift-bundler/Subcommands/Build.swift +++ b/Sources/swift-bundler/Subcommands/Build.swift @@ -81,9 +81,10 @@ extension Bundler { command += " --arch arm64 --arch x86_64" } let exitStatus = Shell.getExitStatus(command, packageDir, silent: false, lineHandler: { line in - if shouldBuildUniversal && line.split(separator: ":")[0].last == "%" { + let parts = line.split(separator: ":") + if shouldBuildUniversal && !parts.isEmpty && parts[0].last == "%" { // The output style changes completely in universal builds for whatever reason :) - if let percentage = Double(line.split(separator: ":")[0].dropLast()) { + if let percentage = Double(parts[0].dropLast()) { updateProgress(line, 0.8 * (percentage / 100) + 0.1, shouldLog: false) } } else if line.starts(with: "[") {