mirror of
https://github.com/ninxsoft/Mist.git
synced 2025-05-28 14:04:49 -04:00
Refactor Architecture
This commit is contained in:
parent
49eae0e017
commit
5c804f50e3
6 changed files with 56 additions and 23 deletions
|
@ -132,6 +132,7 @@
|
|||
39FF05FA285985DD00A86670 /* SettingsAboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39FF05F9285985DD00A86670 /* SettingsAboutView.swift */; };
|
||||
573A235E2A285E8900EC9470 /* SQLite in Frameworks */ = {isa = PBXBuildFile; productRef = 573A235D2A285E8900EC9470 /* SQLite */; };
|
||||
573A23602A285EAE00EC9470 /* FullDiskAccessVerifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573A235F2A285EAE00EC9470 /* FullDiskAccessVerifier.swift */; };
|
||||
573A23622A28711C00EC9470 /* Architecture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 573A23612A28711C00EC9470 /* Architecture.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
|
@ -273,6 +274,7 @@
|
|||
39FF05F72859851800A86670 /* SettingsApplicationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsApplicationsView.swift; sourceTree = "<group>"; };
|
||||
39FF05F9285985DD00A86670 /* SettingsAboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsAboutView.swift; sourceTree = "<group>"; };
|
||||
573A235F2A285EAE00EC9470 /* FullDiskAccessVerifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FullDiskAccessVerifier.swift; sourceTree = "<group>"; };
|
||||
573A23612A28711C00EC9470 /* Architecture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Architecture.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -395,6 +397,7 @@
|
|||
390451C32856E4A500E0B563 /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
573A23612A28711C00EC9470 /* Architecture.swift */,
|
||||
39CB5E3C293F5C2E00CFDBB8 /* Catalog.swift */,
|
||||
390451E428574F0000E0B563 /* CatalogType.swift */,
|
||||
39CB5E3E2941486D00CFDBB8 /* CatalogSeedType.swift */,
|
||||
|
@ -775,6 +778,7 @@
|
|||
3935F47C2864434B00760AB0 /* SettingsGeneralNotificationsView.swift in Sources */,
|
||||
3935F4C7286B54E200760AB0 /* SparkleUpdater.swift in Sources */,
|
||||
393F35BE2864197F005B7165 /* PrivilegedHelperTool.swift in Sources */,
|
||||
573A23622A28711C00EC9470 /* Architecture.swift in Sources */,
|
||||
390451B92856E24200E0B563 /* Firmware.swift in Sources */,
|
||||
390451CE2856F42800E0B563 /* DownloadType.swift in Sources */,
|
||||
3935F4CB286C1EC500760AB0 /* DownloadView.swift in Sources */,
|
||||
|
|
26
Mist/Model/Architecture.swift
Normal file
26
Mist/Model/Architecture.swift
Normal file
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// Architecture.swift
|
||||
// Mist
|
||||
//
|
||||
// Created by Nindi Gill on 1/6/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum Architecture: String {
|
||||
case appleSilicon = "arm64"
|
||||
case intel = "x86_64"
|
||||
|
||||
var identifier: String {
|
||||
rawValue
|
||||
}
|
||||
|
||||
var description: String {
|
||||
switch self {
|
||||
case .appleSilicon:
|
||||
return "Apple Silicon"
|
||||
case .intel:
|
||||
return "Intel-based"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -103,8 +103,8 @@ struct Firmware: Decodable, Hashable, Identifiable {
|
|||
/// - Returns: An array of Firmware build strings.
|
||||
static func supportedBuilds() throws -> [String] {
|
||||
|
||||
guard let architecture: String = Hardware.architecture,
|
||||
architecture.contains("arm64"),
|
||||
guard let architecture: Architecture = Hardware.architecture,
|
||||
architecture == .appleSilicon,
|
||||
let modelIdentifier: String = Hardware.modelIdentifier,
|
||||
let url: URL = URL(string: Firmware.deviceURLTemplate.replacingOccurrences(of: "MODELIDENTIFIER", with: modelIdentifier)) else {
|
||||
return []
|
||||
|
|
|
@ -10,36 +10,40 @@ import Foundation
|
|||
/// Hardware Struct used to retrieve Hardware information.
|
||||
struct Hardware {
|
||||
|
||||
/// Hardware Architecture (arm64 or x86_64).
|
||||
static var architecture: String? {
|
||||
/// Hardware Architecture (Apple Silicon or Intel).
|
||||
static var architecture: Architecture? {
|
||||
|
||||
guard let cString: UnsafePointer<CChar> = NXGetLocalArchInfo().pointee.name else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return String(cString: cString)
|
||||
let string: String = String(cString: cString)
|
||||
|
||||
if string.contains(Architecture.appleSilicon.identifier) {
|
||||
return .appleSilicon
|
||||
}
|
||||
|
||||
if string.contains(Architecture.intel.identifier) {
|
||||
return .intel
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
/// Hardware Board ID (Intel).
|
||||
static var boardID: String? {
|
||||
|
||||
guard let architecture: String = architecture else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return architecture.contains("x86_64") ? registryProperty(for: "board-id") : nil
|
||||
architecture == .intel ? registryProperty(for: "board-id") : nil
|
||||
}
|
||||
/// Hardware Device ID (Apple Silicon or Intel T2).
|
||||
static var deviceID: String? {
|
||||
|
||||
guard let architecture: String = architecture else {
|
||||
return nil
|
||||
}
|
||||
|
||||
if architecture.contains("x86_64") {
|
||||
return registryProperty(for: "bridge-model")?.uppercased()
|
||||
} else {
|
||||
switch architecture {
|
||||
case .appleSilicon:
|
||||
return registryProperty(for: "compatible")?.components(separatedBy: "\0").first?.uppercased()
|
||||
case .intel:
|
||||
return registryProperty(for: "bridge-model")?.uppercased()
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
/// Hardware Model Identifier (Apple Silicon or Intel).
|
||||
|
|
|
@ -323,8 +323,8 @@ struct Installer: Decodable, Hashable, Identifiable {
|
|||
// macOS Catalina 10.15 or older
|
||||
if version.range(of: "^10\\.", options: .regularExpression) != nil {
|
||||
|
||||
if let architecture: String = Hardware.architecture,
|
||||
architecture.contains("arm64") {
|
||||
if let architecture: Architecture = Hardware.architecture,
|
||||
architecture == .appleSilicon {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -34,13 +34,12 @@ struct ListRow: View {
|
|||
}
|
||||
private var compatibilityMessage: String {
|
||||
|
||||
guard let architecture: String = Hardware.architecture else {
|
||||
guard let architecture: Architecture = Hardware.architecture else {
|
||||
return "Invalid architecture!"
|
||||
}
|
||||
|
||||
let deviceType: String = architecture.contains("arm64") ? "Apple Silicon" : "Intel-based"
|
||||
let operation: String = type == .firmware ? "restore" : "re-install"
|
||||
let string: String = "This macOS \(type.description) download cannot be used to \(operation) macOS on this \(deviceType) Mac.\n\nAre you sure you want to continue?"
|
||||
let string: String = "This macOS \(type.description) download cannot be used to \(operation) macOS on this \(architecture.description) Mac.\n\nAre you sure you want to continue?"
|
||||
return string
|
||||
}
|
||||
private var privilegedHelperToolTitle: String {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue