Skip to content

Commit

Permalink
Merge branch 'deployment-target-macos-12' into deployment-target-maco…
Browse files Browse the repository at this point in the history
…s-13
  • Loading branch information
F1248 committed Jan 6, 2025
2 parents 6804091 + 0750070 commit 9b98cfc
Show file tree
Hide file tree
Showing 18 changed files with 201 additions and 185 deletions.
2 changes: 1 addition & 1 deletion Genius/Extensions/Foundation/Pipe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import Foundation
extension Pipe {

func read() -> String? {
try? String(fileHandleForReading.readToEnd())
try? String(fileHandleForReading.readToEnd())?.trimmingCharacters(in: .whitespacesAndNewlines)
}
}
24 changes: 12 additions & 12 deletions Genius/Extensions/Swift/Bool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ extension Bool? {
bool.map(!)
}

static func &&? (lhs: Self, rhs: Self) -> Self {
if let lhs, let rhs {
lhs && rhs
} else if [lhs, rhs].contains(false) {
false
} else { nil }
static func &&? (lhs: Self, rhs: @autoclosure () -> Self) -> Self {
switch lhs {
case true: rhs()
case false: false
default: rhs() == false ? false : nil
}
}

static func ||? (lhs: Self, rhs: Self) -> Self {
if let lhs, let rhs {
lhs || rhs
} else if [lhs, rhs].contains(true) {
true
} else { nil }
static func ||? (lhs: Self, rhs: @autoclosure () -> Self) -> Self {
switch lhs {
case true: true
case false: rhs()
default: rhs() == true ? true : nil
}
}
}
14 changes: 7 additions & 7 deletions Genius/Extensions/Swift/Optional.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ extension Optional where Wrapped: Equatable {

extension Optional where Wrapped: Comparable {

static func <? (lhs: Self, rhs: Self) -> Bool? {
guard let lhs, let rhs else { return nil }
return lhs < rhs
}

static func >? (lhs: Self, rhs: Self) -> Bool? {
guard let lhs, let rhs else { return nil }
return lhs > rhs
}

static func <=? (lhs: Self, rhs: Self) -> Bool? {
!?(lhs >? rhs)
static func <? (lhs: Self, rhs: Self) -> Bool? {
guard let lhs, let rhs else { return nil }
return lhs < rhs
}

static func >=? (lhs: Self, rhs: Self) -> Bool? {
!?(lhs <? rhs)
}

static func <=? (lhs: Self, rhs: Self) -> Bool? {
!?(lhs >? rhs)
}
}
4 changes: 2 additions & 2 deletions Genius/Models/Operators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ prefix operator !?

infix operator ==?: ComparisonPrecedence
infix operator !=?: ComparisonPrecedence
infix operator <?: ComparisonPrecedence
infix operator >?: ComparisonPrecedence
infix operator <=?: ComparisonPrecedence
infix operator <?: ComparisonPrecedence
infix operator >=?: ComparisonPrecedence
infix operator <=?: ComparisonPrecedence
infix operator &&?: LogicalConjunctionPrecedence
infix operator ||?: LogicalDisjunctionPrecedence
12 changes: 6 additions & 6 deletions Genius/Models/SystemInformation/Hardware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ extension SystemInformation {
let regionInfo = IORegistry(class: "IOPlatformExpertDevice").read("region-info") as String?
else { return nil }
return modelNumber + regionInfo
},
}(),
applicable: CPU.type.value == .appleSilicon
)
static let regulatoryNumber = SystemInformationData<String?>(
{ IORegistry(class: "IOPlatformExpertDevice").read("regulatory-model-number") },
IORegistry(class: "IOPlatformExpertDevice").read("regulatory-model-number"),
applicable: CPU.type.value == .appleSilicon &&? !?isVirtualMachine.value
)
// periphery:ignore
Expand Down Expand Up @@ -91,9 +91,9 @@ extension SystemInformation {
static let differentTypes = SystemInformationData<Bool?>(type.value == .appleSilicon &&? !?Model.isVirtualMachine.value)
static let total = SystemInformationData<Int?>(Sysctl.read("hw.physicalcpu"))
static let performance =
SystemInformationData<Int?>({ Sysctl.read("hw.perflevel0.physicalcpu") }, applicable: differentTypes.value)
SystemInformationData<Int?>(Sysctl.read("hw.perflevel0.physicalcpu"), applicable: differentTypes.value)
static let efficiency =
SystemInformationData<Int?>({ Sysctl.read("hw.perflevel1.physicalcpu") }, applicable: differentTypes.value)
SystemInformationData<Int?>(Sysctl.read("hw.perflevel1.physicalcpu"), applicable: differentTypes.value)
}

static let type = SystemInformationData<CPUType>({
Expand All @@ -107,7 +107,7 @@ extension SystemInformation {
}())
static let name = SystemInformationData<String?>(Sysctl.read("machdep.cpu.brand_string"))
static let frequency =
SystemInformationData<Frequency?>({ Sysctl.read("hw.cpufrequency").map(Frequency.init) }, applicable: type.value == .intel)
SystemInformationData<Frequency?>(Sysctl.read("hw.cpufrequency").map(Frequency.init), applicable: type.value == .intel)
}

static let memory = SystemInformationData<InformationStorage?>(Sysctl.read("hw.memsize").map(InformationStorage.init))
Expand All @@ -119,7 +119,7 @@ extension SystemInformation {
static let hardwareUUID =
SystemInformationData<String?>(IORegistry(class: "IOPlatformExpertDevice").read(kIOPlatformUUIDKey))
static let provisioningUDID = SystemInformationData<String?>(
{ SystemProfiler.hardware?["provisioning_UDID"] as? String ?? (CPU.type.value == .intel ? hardwareUUID.value : nil) },
SystemProfiler.hardware?["provisioning_UDID"] as? String ?? (CPU.type.value == .intel ? hardwareUUID.value : nil),
applicable: Software.OS.bootMode.value !=? .recovery ||? CPU.type.value == .intel
)
}
Expand Down
22 changes: 11 additions & 11 deletions Genius/Models/SystemInformation/MaintenanceChecks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ extension SystemInformation {
enum TheftProtection {

static let activationLock = SystemInformationData<Bool?>(
{ IORegistry(class: "IODTNVRAMVariables").keyExists("fmm-mobileme-token-FMM") },
IORegistry(class: "IODTNVRAMVariables").keyExists("fmm-mobileme-token-FMM"),
applicable: Hardware.securityChip.value >=? .t2 &&? !?Hardware.Model.isVirtualMachine.value
)
static let firmwarePassword = SystemInformationData<Bool?>(
{ Bool(Process("/usr/sbin/firmwarepasswd", ["-check"], requiresRoot: true)?.runSafe()) },
Bool(Process("/usr/sbin/firmwarepasswd", ["-check"], requiresRoot: true)?.runSafe()),
applicable: Hardware.CPU.type.value == .intel &&? !?Hardware.Model.isVirtualMachine.value
)
}

enum DataSecurity {

static let fileVault = SystemInformationData<Bool?>(
{ Bool(Process("/usr/bin/fdesetup", ["status"])?.runSafe()) },
Bool(Process("/usr/bin/fdesetup", ["status"])?.runSafe()),
applicable: Software.OS.bootMode.value !=? .recovery
)
}

enum MalwareProtection {

static let systemIntegrityProtection = SystemInformationData<Bool?>(
{ Bool(Process("/usr/bin/csrutil", ["status"])?.runSafe()) },
Bool(Process("/usr/bin/csrutil", ["status"])?.runSafe()),
applicable: Software.OS.bootMode.value !=? .recovery
)
static let firewall = SystemInformationData<Bool?>(
{ Bool(Process("/usr/libexec/ApplicationFirewall/socketfilterfw", ["--getglobalstate"])?.runSafe()) },
Bool(Process("/usr/libexec/ApplicationFirewall/socketfilterfw", ["--getglobalstate"])?.runSafe()),
applicable: Software.OS.bootMode.value !=? .recovery
)
static let gatekeeper = SystemInformationData<Bool?>(Bool(Process("/usr/sbin/spctl", ["--status"])?.runSafe()))
Expand All @@ -48,27 +48,27 @@ extension SystemInformation {
enum AutomaticUpdates {

static let checkMacOS = SystemInformationData<Bool?>(
{ UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "AutomaticCheckEnabled") },
UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "AutomaticCheckEnabled"),
applicable: { if #unavailable(macOS 15) { true } else { false } }() &&? Software.OS.bootMode.value !=? .recovery
)
static let downloadMacOS = SystemInformationData<Bool?>(
{ UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "AutomaticDownload") },
UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "AutomaticDownload"),
applicable: Software.OS.bootMode.value !=? .recovery
)
static let installMacOS = SystemInformationData<Bool?>(
{ UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "AutomaticallyInstallMacOSUpdates") },
UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "AutomaticallyInstallMacOSUpdates"),
applicable: Software.OS.bootMode.value !=? .recovery
)
static let installCritical = SystemInformationData<Bool?>(
{ UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "CriticalUpdateInstall") },
UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "CriticalUpdateInstall"),
applicable: Software.OS.bootMode.value !=? .recovery
)
static let installConfigurationData = SystemInformationData<Bool?>(
{ UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "ConfigDataInstall") },
UserDefaults.read("/Library/Preferences/com.apple.SoftwareUpdate", "ConfigDataInstall"),
applicable: Software.OS.bootMode.value !=? .recovery
)
static let installAppStoreApps = SystemInformationData<Bool?>(
{ UserDefaults.read("/Library/Preferences/com.apple.commerce", "AutoUpdate") },
UserDefaults.read("/Library/Preferences/com.apple.commerce", "AutoUpdate"),
applicable: Software.OS.bootMode.value !=? .recovery
)
}
Expand Down
12 changes: 5 additions & 7 deletions Genius/Models/SystemInformation/Software.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ extension SystemInformation {
enum SMC {

static let version = SystemInformationData<String?>(
{ SystemProfiler.hardware?["SMC_version_system"] as? String },
SystemProfiler.hardware?["SMC_version_system"] as? String,
applicable: Hardware.securityChip.value <=? .t1 &&? OS.bootMode.value !=? .recovery
)
}

enum Firmware {

static let version = SystemInformationData<String?>(
{ SystemProfiler.hardware?["boot_rom_version"] as? String },
SystemProfiler.hardware?["boot_rom_version"] as? String,
applicable: OS.bootMode.value !=? .recovery
)
}
Expand Down Expand Up @@ -57,12 +57,10 @@ extension SystemInformation {
safe ? .safe : .normal
} else { nil }
}())
static let bootVolume = SystemInformationData<String?>(
{ SystemProfiler.software?["boot_volume"] as? String },
applicable: bootMode.value !=? .recovery
)
static let bootVolume =
SystemInformationData<String?>(SystemProfiler.software?["boot_volume"] as? String, applicable: bootMode.value !=? .recovery)
static let loaderVersion = SystemInformationData<String?>(
{ SystemProfiler.hardware?["os_loader_version"] as? String },
SystemProfiler.hardware?["os_loader_version"] as? String,
applicable: bootMode.value !=? .recovery
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct SystemInformationData<T: Sendable>: SystemInformationDataProtocol {
self.applicable = true
}

init<W>(_ value: () -> T, applicable: Bool?) where T == W? {
init<W>(_ value: @autoclosure () -> T, applicable: Bool?) where T == W? {
self.value = applicable ?? true ? value() : nil
self.applicable = applicable
}
Expand Down
9 changes: 2 additions & 7 deletions Genius/ViewModels/Tabs/CustomTabContentBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
@resultBuilder
enum CustomTabContentBuilder {

static func buildBlock(_ tabs: [CustomTab]) -> [CustomTab] {
tabs
}

static func buildBlock(_ tabs: CustomTab...) -> [CustomTab] {
tabs
}
static func buildBlock(_ tabs: [CustomTab]) -> [CustomTab] { tabs }
static func buildBlock(_ tabs: CustomTab...) -> [CustomTab] { tabs }
}
5 changes: 2 additions & 3 deletions Genius/Views/Common/VaryingText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
//

import Defaults
import SwiftUI
import SwiftUICore

struct VaryingText: View {

@AppStorage(Defaults.Keys.interfaceMode.name)
var interfaceMode: Settings.InterfaceMode = Defaults.Keys.interfaceMode.defaultValue
@Default(.interfaceMode)
var interfaceMode: Settings.InterfaceMode

let key: LocalizedStringKey

Expand Down
8 changes: 4 additions & 4 deletions Genius/Views/Settings/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import SwiftUICore

struct SettingsView: View {

@AppStorage(Defaults.Keys.interfaceMode.name)
var interfaceMode: Settings.InterfaceMode = Defaults.Keys.interfaceMode.defaultValue
@AppStorage(Defaults.Keys.developmentMode.name)
var developmentMode: Bool = Defaults.Keys.developmentMode.defaultValue
@Default(.interfaceMode)
var interfaceMode: Settings.InterfaceMode
@Default(.developmentMode)
var developmentMode: Bool

var body: some View {
Text("Settings")
Expand Down
49 changes: 0 additions & 49 deletions GeniusTests/OptionalComparisonOpearatorsTests.swift

This file was deleted.

29 changes: 0 additions & 29 deletions GeniusTests/OptionalEquationOpearatorsTests.swift

This file was deleted.

Loading

0 comments on commit 9b98cfc

Please sign in to comment.