From 42577933f88577a3be896923341b63e2cbbc0a87 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 19 Sep 2024 15:19:13 +0200 Subject: [PATCH] Swift 6 Changes + Bump Version --- Whisky.xcodeproj/project.pbxproj | 16 ++++++++-------- .../xcshareddata/swiftpm/Package.resolved | 10 +++++----- Whisky/Utils/Winetricks.swift | 2 +- Whisky/View Models/BottleVM.swift | 18 ++++++++++++------ Whisky/Views/ContentView.swift | 2 +- Whisky/Views/FileOpenView.swift | 2 +- Whisky/Views/WhiskyApp.swift | 16 ++++++++-------- WhiskyCmd/Main.swift | 2 +- .../Extensions/Process+Extensions.swift | 9 ++++++--- WhiskyKit/Sources/WhiskyKit/PE/Section.swift | 2 +- WhiskyKit/Sources/WhiskyKit/Tar.swift | 4 ++-- .../Sources/WhiskyKit/Whisky/BottleData.swift | 2 +- .../WhiskyKit/Whisky/BottleSettings.swift | 2 +- 13 files changed, 48 insertions(+), 39 deletions(-) diff --git a/Whisky.xcodeproj/project.pbxproj b/Whisky.xcodeproj/project.pbxproj index b69cb40ba..33a1ce885 100644 --- a/Whisky.xcodeproj/project.pbxproj +++ b/Whisky.xcodeproj/project.pbxproj @@ -781,7 +781,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 41; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Whisky/Preview Content\""; DEVELOPMENT_TEAM = ""; @@ -800,7 +800,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 2.3.2; + MARKETING_VERSION = 2.3.3; PRODUCT_BUNDLE_IDENTIFIER = com.isaacmarovitz.Whisky; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -820,7 +820,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 41; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Whisky/Preview Content\""; DEVELOPMENT_TEAM = ""; @@ -839,7 +839,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 14.0; - MARKETING_VERSION = 2.3.2; + MARKETING_VERSION = 2.3.3; PRODUCT_BUNDLE_IDENTIFIER = com.isaacmarovitz.Whisky; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -910,7 +910,7 @@ CODE_SIGN_ENTITLEMENTS = WhiskyThumbnail/WhiskyThumbnail.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 41; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=macosx*]" = 92S3SG4PTH; @@ -927,7 +927,7 @@ "@executable_path/../../../../Frameworks", ); LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MARKETING_VERSION = 2.3.2; + MARKETING_VERSION = 2.3.3; PRODUCT_BUNDLE_IDENTIFIER = com.isaacmarovitz.Whisky.WhiskyThumbnail; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -946,7 +946,7 @@ CODE_SIGN_ENTITLEMENTS = WhiskyThumbnail/WhiskyThumbnail.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Developer ID Application"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 40; + CURRENT_PROJECT_VERSION = 41; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=macosx*]" = 92S3SG4PTH; @@ -963,7 +963,7 @@ "@executable_path/../../../../Frameworks", ); LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MARKETING_VERSION = 2.3.2; + MARKETING_VERSION = 2.3.3; PRODUCT_BUNDLE_IDENTIFIER = com.isaacmarovitz.Whisky.WhiskyThumbnail; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Whisky.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Whisky.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 067e72711..9d4f8ee59 100644 --- a/Whisky.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Whisky.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/SwiftPackageIndex/SemanticVersion", "state" : { - "revision" : "a70840d5fca686ae3bd2fcf8aecc5ded0bd4f125", - "version" : "0.3.6" + "revision" : "ea8eea9d89842a29af1b8e6c7677f1c86e72fa42", + "version" : "0.4.0" } }, { @@ -24,7 +24,7 @@ "location" : "https://github.com/sparkle-project/Sparkle", "state" : { "branch" : "2.x", - "revision" : "b7b858dbf385cdd1fe1ab8a3f3ee8586fa850d5d" + "revision" : "8de8db001ea3c781f5e2b1c9abe851209dd8c08a" } }, { @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-argument-parser.git", "state" : { - "revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531", - "version" : "1.2.3" + "revision" : "41982a3656a71c768319979febd796c6fd111d5c", + "version" : "1.5.0" } }, { diff --git a/Whisky/Utils/Winetricks.swift b/Whisky/Utils/Winetricks.swift index 159162c81..b218f12db 100644 --- a/Whisky/Utils/Winetricks.swift +++ b/Whisky/Utils/Winetricks.swift @@ -87,7 +87,7 @@ class Winetricks { do { let (data, _) = try await URLSession.shared.data(from: verbsURL) - verbs = String(decoding: data, as: UTF8.self) + verbs = String(data: data, encoding: .utf8) } catch { return [] } diff --git a/Whisky/View Models/BottleVM.swift b/Whisky/View Models/BottleVM.swift index aa0c09dcc..7cb864d9b 100644 --- a/Whisky/View Models/BottleVM.swift +++ b/Whisky/View Models/BottleVM.swift @@ -40,7 +40,7 @@ final class BottleVM: ObservableObject, @unchecked Sendable { func createNewBottle(bottleName: String, winVersion: WinVersion, bottleURL: URL) -> URL { let newBottleDir = bottleURL.appending(path: UUID().uuidString) - Task.detached { @MainActor in + Task.detached { var bottleId: Bottle? do { try FileManager.default.createDirectory(atPath: newBottleDir.path(percentEncoded: false), @@ -48,7 +48,9 @@ final class BottleVM: ObservableObject, @unchecked Sendable { let bottle = Bottle(bottleUrl: newBottleDir, inFlight: true) bottleId = bottle - self.bottles.append(bottle) + await MainActor.run { + self.bottles.append(bottle) + } bottle.settings.windowsVersion = winVersion bottle.settings.name = bottleName @@ -56,13 +58,17 @@ final class BottleVM: ObservableObject, @unchecked Sendable { let wineVer = try await Wine.wineVersion() bottle.settings.wineVersion = SemanticVersion(wineVer) ?? SemanticVersion(0, 0, 0) // Add record - self.bottlesList.paths.append(newBottleDir) - self.loadBottles() + await MainActor.run { + self.bottlesList.paths.append(newBottleDir) + self.loadBottles() + } } catch { print("Failed to create new bottle: \(error)") if let bottle = bottleId { - if let index = self.bottles.firstIndex(of: bottle) { - self.bottles.remove(at: index) + await MainActor.run { + if let index = self.bottles.firstIndex(of: bottle) { + self.bottles.remove(at: index) + } } } } diff --git a/Whisky/Views/ContentView.swift b/Whisky/Views/ContentView.swift index 19d9a1f9f..c15e5c733 100644 --- a/Whisky/Views/ContentView.swift +++ b/Whisky/Views/ContentView.swift @@ -19,7 +19,7 @@ import SwiftUI import UniformTypeIdentifiers import WhiskyKit -@preconcurrency import SemanticVersion +import SemanticVersion struct ContentView: View { @AppStorage("selectedBottleURL") private var selectedBottleURL: URL? diff --git a/Whisky/Views/FileOpenView.swift b/Whisky/Views/FileOpenView.swift index eb3602b39..a7ca4b0e8 100644 --- a/Whisky/Views/FileOpenView.swift +++ b/Whisky/Views/FileOpenView.swift @@ -79,7 +79,7 @@ struct FileOpenView: View { if let bottle = bottles.first(where: { $0.url == selection }) { Task.detached(priority: .userInitiated) { do { - if await fileURL.pathExtension == "bat" { + if fileURL.pathExtension == "bat" { try await Wine.runBatchFile(url: fileURL, bottle: bottle) } else { diff --git a/Whisky/Views/WhiskyApp.swift b/Whisky/Views/WhiskyApp.swift index 9e03f19ba..52ce3ebab 100644 --- a/Whisky/Views/WhiskyApp.swift +++ b/Whisky/Views/WhiskyApp.swift @@ -179,14 +179,14 @@ struct WhiskyApp: App { getconf.waitUntilExit() let getconfOutput = pipe.fileHandleForReading.readDataToEndOfFile() - let getconfOutputString = String(decoding: getconfOutput, as: UTF8.self) - - let d3dmPath = URL(fileURLWithPath: getconfOutputString.trimmingCharacters(in: .whitespacesAndNewlines)) - .appending(path: "d3dm").path - do { - try FileManager.default.removeItem(atPath: d3dmPath) - } catch { - return + if let getconfOutputString = String(data: getconfOutput, encoding: .utf8) { + let d3dmPath = URL(fileURLWithPath: getconfOutputString.trimmingCharacters(in: .whitespacesAndNewlines)) + .appending(path: "d3dm").path + do { + try FileManager.default.removeItem(atPath: d3dmPath) + } catch { + return + } } } } diff --git a/WhiskyCmd/Main.swift b/WhiskyCmd/Main.swift index 0dd88bb4c..fc599895a 100644 --- a/WhiskyCmd/Main.swift +++ b/WhiskyCmd/Main.swift @@ -21,7 +21,7 @@ import WhiskyKit import SwiftyTextTable import Progress import SemanticVersion -@preconcurrency import ArgumentParser +import ArgumentParser @main struct Whisky: ParsableCommand { diff --git a/WhiskyKit/Sources/WhiskyKit/Extensions/Process+Extensions.swift b/WhiskyKit/Sources/WhiskyKit/Extensions/Process+Extensions.swift index ccd6ea60a..b19c75f7c 100644 --- a/WhiskyKit/Sources/WhiskyKit/Extensions/Process+Extensions.swift +++ b/WhiskyKit/Sources/WhiskyKit/Extensions/Process+Extensions.swift @@ -121,8 +121,11 @@ public extension Process { extension FileHandle { func nextLine() -> String? { - let line = String(decoding: availableData, as: UTF8.self) - guard !line.isEmpty else { return nil } - return line + if let line = String(data: availableData, encoding: .utf8) { + guard !line.isEmpty else { return nil } + return line + } + + return nil } } diff --git a/WhiskyKit/Sources/WhiskyKit/PE/Section.swift b/WhiskyKit/Sources/WhiskyKit/PE/Section.swift index bde35162c..4a3dd3f0d 100644 --- a/WhiskyKit/Sources/WhiskyKit/PE/Section.swift +++ b/WhiskyKit/Sources/WhiskyKit/PE/Section.swift @@ -40,7 +40,7 @@ extension PEFile { do { try handle.seek(toOffset: UInt64(offset)) if let data = try handle.read(upToCount: 8) { - let string = String(decoding: data, as: UTF8.self) + let string = String(data: data, encoding: .utf8) ?? "" self.name = string.replacingOccurrences(of: "\0", with: "") } else { self.name = "" diff --git a/WhiskyKit/Sources/WhiskyKit/Tar.swift b/WhiskyKit/Sources/WhiskyKit/Tar.swift index 1cf882d1c..5bca1dc33 100644 --- a/WhiskyKit/Sources/WhiskyKit/Tar.swift +++ b/WhiskyKit/Sources/WhiskyKit/Tar.swift @@ -33,7 +33,7 @@ public class Tar { try process.run() if let output = try pipe.fileHandleForReading.readToEnd() { - let outputString = String(decoding: output, as: UTF8.self) + let outputString = String(data: output, encoding: .utf8) ?? "" process.waitUntilExit() let status = process.terminationStatus if status != 0 { @@ -54,7 +54,7 @@ public class Tar { try process.run() if let output = try pipe.fileHandleForReading.readToEnd() { - let outputString = String(decoding: output, as: UTF8.self) + let outputString = String(data: output, encoding: .utf8) ?? "" process.waitUntilExit() let status = process.terminationStatus if status != 0 { diff --git a/WhiskyKit/Sources/WhiskyKit/Whisky/BottleData.swift b/WhiskyKit/Sources/WhiskyKit/Whisky/BottleData.swift index cda55ba0a..df40ce1ab 100644 --- a/WhiskyKit/Sources/WhiskyKit/Whisky/BottleData.swift +++ b/WhiskyKit/Sources/WhiskyKit/Whisky/BottleData.swift @@ -17,7 +17,7 @@ // import Foundation -@preconcurrency import SemanticVersion +import SemanticVersion public struct BottleData: Codable { public static let containerDir = FileManager.default.homeDirectoryForCurrentUser diff --git a/WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift b/WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift index 2129910af..cbd9692a0 100644 --- a/WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift +++ b/WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift @@ -17,7 +17,7 @@ // import Foundation -@preconcurrency import SemanticVersion +import SemanticVersion import os.log public struct PinnedProgram: Codable, Hashable, Equatable {