Skip to content

Commit

Permalink
Increase minimum macOS version to 10.13, since Swift 5.7 is already u…
Browse files Browse the repository at this point in the history
…sed, 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 <[email protected]>
  • Loading branch information
rgoldberg committed Oct 27, 2024
1 parent b819488 commit fb628f0
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.7
5.7.1
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// 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

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.
Expand Down
2 changes: 1 addition & 1 deletion Package/Distribution.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<options customize="never" require-scripts="false"/>
<volume-check>
<allowed-os-versions>
<os-version min="10.11"/>
<os-version min="10.13"/>
</allowed-os-versions>
</volume-check>
<choices-outline>
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
88 changes: 15 additions & 73 deletions Sources/mas/AppStore/ISStoreAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,81 +14,23 @@ private let timeout = 30.0

extension ISStoreAccount: StoreAccount {
static var primaryAccount: Promise<ISStoreAccount> {
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<ISStoreAccount> {
// 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<ISStoreAccount> 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<ISStoreAccount> { 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<ISStoreAccount> {
// Signing in is no longer possible as of High Sierra.
// https://github.com/mas-cli/mas/issues/164
Promise(error: MASError.notSupported)
}
}
8 changes: 1 addition & 7 deletions Sources/mas/Commands/SignOut.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
11 changes: 2 additions & 9 deletions Sources/mas/ExternalCommands/ExternalCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
2 changes: 1 addition & 1 deletion Tests/masTests/Commands/SignInSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions script/bottle
Original file line number Diff line number Diff line change
Expand Up @@ -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'))"
Expand Down

0 comments on commit fb628f0

Please sign in to comment.