Skip to content

Commit

Permalink
Swift 6 Changes + Bump Version
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Sep 19, 2024
1 parent 4e4911f commit 4257793
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 39 deletions.
16 changes: 8 additions & 8 deletions Whisky.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -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 = "";
Expand All @@ -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 = "";
Expand All @@ -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 = "";
Expand Down Expand Up @@ -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;
Expand All @@ -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 = "";
Expand All @@ -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;
Expand All @@ -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 = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand All @@ -24,16 +24,16 @@
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"branch" : "2.x",
"revision" : "b7b858dbf385cdd1fe1ab8a3f3ee8586fa850d5d"
"revision" : "8de8db001ea3c781f5e2b1c9abe851209dd8c08a"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.2.3"
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
"version" : "1.5.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Whisky/Utils/Winetricks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
}
Expand Down
18 changes: 12 additions & 6 deletions Whisky/View Models/BottleVM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,35 @@ 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),
withIntermediateDirectories: true)
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
try await Wine.changeWinVersion(bottle: bottle, win: winVersion)
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)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Whisky/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import SwiftUI
import UniformTypeIdentifiers
import WhiskyKit
@preconcurrency import SemanticVersion
import SemanticVersion

struct ContentView: View {
@AppStorage("selectedBottleURL") private var selectedBottleURL: URL?
Expand Down
2 changes: 1 addition & 1 deletion Whisky/Views/FileOpenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions Whisky/Views/WhiskyApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
2 changes: 1 addition & 1 deletion WhiskyCmd/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import WhiskyKit
import SwiftyTextTable
import Progress
import SemanticVersion
@preconcurrency import ArgumentParser
import ArgumentParser

@main
struct Whisky: ParsableCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion WhiskyKit/Sources/WhiskyKit/PE/Section.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
4 changes: 2 additions & 2 deletions WhiskyKit/Sources/WhiskyKit/Tar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion WhiskyKit/Sources/WhiskyKit/Whisky/BottleData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//

import Foundation
@preconcurrency import SemanticVersion
import SemanticVersion

public struct BottleData: Codable {
public static let containerDir = FileManager.default.homeDirectoryForCurrentUser
Expand Down
2 changes: 1 addition & 1 deletion WhiskyKit/Sources/WhiskyKit/Whisky/BottleSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//

import Foundation
@preconcurrency import SemanticVersion
import SemanticVersion
import os.log

public struct PinnedProgram: Codable, Hashable, Equatable {
Expand Down

0 comments on commit 4257793

Please sign in to comment.