From fb628f05d55b7b431d19d166fa166fdc96029a69 Mon Sep 17 00:00:00 2001 From: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> Date: Sun, 27 Oct 2024 13:47:17 -0400 Subject: [PATCH] Increase minimum macOS version to 10.13, since Swift 5.7 is already used, which requires Xcode 14+ to compile, which only supports macOS deployment targets 10.13+. Use Swift 5.7.1, which is the newest version of Swift 5.7. Resolve #578 Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> --- .swift-version | 2 +- Makefile | 8 +- Package.swift | 4 +- Package/Distribution.plist | 2 +- README.md | 3 +- Sources/mas/AppStore/ISStoreAccount.swift | 88 ++++--------------- Sources/mas/Commands/SignOut.swift | 8 +- .../ExternalCommands/ExternalCommand.swift | 11 +-- Tests/masTests/Commands/SignInSpec.swift | 2 +- script/bottle | 4 +- 10 files changed, 28 insertions(+), 104 deletions(-) diff --git a/.swift-version b/.swift-version index 760606e1..64ff7ded 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -5.7 +5.7.1 diff --git a/Makefile b/Makefile index 9b85b78f..ec483e05 100644 --- a/Makefile +++ b/Makefile @@ -12,13 +12,7 @@ CMD_NAME = mas SHELL = /bin/sh PREFIX ?= /usr/local -# trunk -# SWIFT_VERSION = swift-DEVELOPMENT-SNAPSHOT-2020-04-23-a - -# Swift 5.3 -# SWIFT_VERSION = swift-5.3-DEVELOPMENT-SNAPSHOT-2020-04-21-a - -SWIFT_VERSION = 5.7 +SWIFT_VERSION = 5.7.1 # set EXECUTABLE_DIRECTORY according to your specific environment # run swift build and see where the output executable is created diff --git a/Package.swift b/Package.swift index 4e48ff7b..c86eb3d0 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.6.1 +// swift-tools-version:5.7.1 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "mas", platforms: [ - .macOS(.v10_11) + .macOS(.v10_13) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Package/Distribution.plist b/Package/Distribution.plist index 09ab7ebd..571cb27e 100644 --- a/Package/Distribution.plist +++ b/Package/Distribution.plist @@ -5,7 +5,7 @@ - + diff --git a/README.md b/README.md index 5f8c4528..96b0ebff 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ sudo port install mas #### 🍻 Custom Homebrew tap We provide a [custom Homebrew tap](https://github.com/mas-cli/homebrew-tap) with pre-built bottles -for all macOS versions since 10.11 (El Capitan). +for all macOS versions since 10.11 (El Capitan). The newest versions of mas, however, are only available +for macOS 10.13+ (High Sierra or newer). To install mas from our tap: diff --git a/Sources/mas/AppStore/ISStoreAccount.swift b/Sources/mas/AppStore/ISStoreAccount.swift index 56b7bd6a..b8fc7654 100644 --- a/Sources/mas/AppStore/ISStoreAccount.swift +++ b/Sources/mas/AppStore/ISStoreAccount.swift @@ -14,81 +14,23 @@ private let timeout = 30.0 extension ISStoreAccount: StoreAccount { static var primaryAccount: Promise { - if #available(macOS 10.13, *) { - return race( - Promise { seal in - ISServiceProxy.genericShared().accountService - .primaryAccount { storeAccount in - seal.fulfill(storeAccount) - } - }, - after(seconds: timeout) - .then { - Promise(error: MASError.notSignedIn) + race( + Promise { seal in + ISServiceProxy.genericShared().accountService + .primaryAccount { storeAccount in + seal.fulfill(storeAccount) } - ) - } - - return .value(CKAccountStore.shared().primaryAccount) + }, + after(seconds: timeout) + .then { + Promise(error: MASError.notSignedIn) + } + ) } - static func signIn(appleID: String, password: String, systemDialog: Bool) -> Promise { - // swift-format-ignore: UseEarlyExits - if #available(macOS 10.13, *) { - // Signing in is no longer possible as of High Sierra. - // https://github.com/mas-cli/mas/issues/164 - return Promise(error: MASError.notSupported) - // swiftlint:disable:next superfluous_else - } else { - return - primaryAccount - .then { account -> Promise in - if account.isSignedIn { - return Promise(error: MASError.alreadySignedIn(asAppleID: account.identifier)) - } - - let password = - password.isEmpty && !systemDialog - ? String(validatingUTF8: getpass("Password: ")) ?? "" - : password - - guard !password.isEmpty || systemDialog else { - return Promise(error: MASError.noPasswordProvided) - } - - let context = ISAuthenticationContext(accountID: 0) - context.appleIDOverride = appleID - - let signInPromise = - Promise { seal in - let accountService = ISServiceProxy.genericShared().accountService - accountService.setStoreClient(ISStoreClient(storeClientType: 0)) - accountService.signIn(with: context) { success, storeAccount, error in - if success, let storeAccount { - seal.fulfill(storeAccount) - } else { - seal.reject(MASError.signInFailed(error: error as NSError?)) - } - } - } - - if systemDialog { - return signInPromise - } - - context.demoMode = true - context.demoAccountName = appleID - context.demoAccountPassword = password - context.demoAutologinMode = true - - return race( - signInPromise, - after(seconds: timeout) - .then { - Promise(error: MASError.signInFailed(error: nil)) - } - ) - } - } + static func signIn(appleID _: String, password _: String, systemDialog _: Bool) -> Promise { + // Signing in is no longer possible as of High Sierra. + // https://github.com/mas-cli/mas/issues/164 + Promise(error: MASError.notSupported) } } diff --git a/Sources/mas/Commands/SignOut.swift b/Sources/mas/Commands/SignOut.swift index 6f55e76f..45cf9a5e 100644 --- a/Sources/mas/Commands/SignOut.swift +++ b/Sources/mas/Commands/SignOut.swift @@ -18,13 +18,7 @@ extension MAS { /// Runs the command. func run() throws { - if #available(macOS 10.13, *) { - ISServiceProxy.genericShared().accountService.signOut() - } else { - // Using CKAccountStore to sign out does nothing on High Sierra - // https://github.com/mas-cli/mas/issues/129 - CKAccountStore.shared().signOut() - } + ISServiceProxy.genericShared().accountService.signOut() } } } diff --git a/Sources/mas/ExternalCommands/ExternalCommand.swift b/Sources/mas/ExternalCommands/ExternalCommand.swift index 2168a05d..b5a34873 100644 --- a/Sources/mas/ExternalCommands/ExternalCommand.swift +++ b/Sources/mas/ExternalCommands/ExternalCommand.swift @@ -56,15 +56,8 @@ extension ExternalCommand { process.standardOutput = stdoutPipe process.standardError = stderrPipe process.arguments = arguments - - if #available(macOS 10.13, *) { - process.executableURL = URL(fileURLWithPath: binaryPath) - try process.run() - } else { - process.launchPath = binaryPath - process.launch() - } - + process.executableURL = URL(fileURLWithPath: binaryPath) + try process.run() process.waitUntilExit() } } diff --git a/Tests/masTests/Commands/SignInSpec.swift b/Tests/masTests/Commands/SignInSpec.swift index ceea01c3..57b8292d 100644 --- a/Tests/masTests/Commands/SignInSpec.swift +++ b/Tests/masTests/Commands/SignInSpec.swift @@ -17,7 +17,7 @@ public class SignInSpec: QuickSpec { beforeSuite { MAS.initialize() } - // account command disabled since macOS 10.13 High Sierra https://github.com/mas-cli/mas#known-issues + // signin command disabled since macOS 10.13 High Sierra: https://github.com/mas-cli/mas#known-issues describe("signin command") { it("signs in") { expect { diff --git a/script/bottle b/script/bottle index a54733a3..f4cb48ce 100755 --- a/script/bottle +++ b/script/bottle @@ -17,8 +17,8 @@ BOTTLE_DIR="$BUILD_DIR/bottles" VERSION=$(script/version) ROOT_URL="https://github.com/mas-cli/mas/releases/download/v${VERSION}" -# Supports macOS 10.11 and later -OS_NAMES=(arm64_monterey monterey arm64_big_sur big_sur catalina mojave high_sierra sierra el_capitan) +# Supports macOS 10.13 and later +OS_NAMES=(arm64_monterey monterey arm64_big_sur big_sur catalina mojave high_sierra) # Semantic version number split into a list using Ugly, bash 3 compatible syntax IFS=" " read -r -a CURRENT_OS_VERSION <<<"$(sw_vers -productVersion | sed 's/\./ /g'))"