mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
fix how platforms are architecture filtered
This commit is contained in:
parent
6cf9647840
commit
fc50db1cee
5 changed files with 50 additions and 6 deletions
|
|
@ -11,7 +11,7 @@ import XcodesKit
|
|||
|
||||
struct PlatformsView: View {
|
||||
@EnvironmentObject var appState: AppState
|
||||
@AppStorage("selectedRuntimeArchitecture") private var selectedRuntimeArchitecture: Architecture = .arm64
|
||||
@AppStorage("selectedRuntimeArchitecture") private var selectedVariant: ArchitectureVariant = .universal
|
||||
|
||||
let xcode: Xcode
|
||||
|
||||
|
|
@ -22,7 +22,9 @@ struct PlatformsView: View {
|
|||
appState.downloadableRuntimes.filter {
|
||||
$0.sdkBuildUpdate?.contains(sdkBuild) ?? false &&
|
||||
($0.architectures?.isEmpty ?? true ||
|
||||
$0.architectures?.contains(selectedRuntimeArchitecture) ?? false)
|
||||
($0.architectures?.isUniversal ?? false && selectedVariant == .universal) ||
|
||||
($0.architectures?.isAppleSilicon ?? false && selectedVariant == .appleSilicon)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -35,8 +37,8 @@ struct PlatformsView: View {
|
|||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
if !architectures.isEmpty {
|
||||
Spacer()
|
||||
Picker("Architecture", selection: $selectedRuntimeArchitecture) {
|
||||
ForEach(Architecture.allCases, id: \.self) { arch in
|
||||
Picker("Architecture", selection: $selectedVariant) {
|
||||
ForEach(ArchitectureVariant.allCases, id: \.self) { arch in
|
||||
Label(arch.displayString, systemImage: arch.iconName)
|
||||
.tag(arch)
|
||||
}
|
||||
|
|
@ -73,6 +75,7 @@ struct PlatformsView: View {
|
|||
ForEach(runtime.architectures ?? [], id: \.self) { architecture in
|
||||
TagView(text: architecture.displayString)
|
||||
}
|
||||
|
||||
pathIfAvailable(xcode: xcode, runtime: runtime)
|
||||
|
||||
if runtime.installState == .notInstalled {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{\rtf1\ansi\ansicpg1252\cocoartf2822
|
||||
{\rtf1\ansi\ansicpg1252\cocoartf2865
|
||||
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 .SFNS-Regular;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
{\*\expandedcolortbl;;}
|
||||
|
|
|
|||
|
|
@ -4819,6 +4819,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Architecture" : {
|
||||
|
||||
},
|
||||
"Authenticating" : {
|
||||
"extractionState" : "manual",
|
||||
|
|
@ -5683,6 +5686,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Category" : {
|
||||
|
||||
},
|
||||
"Change" : {
|
||||
"localizations" : {
|
||||
|
|
@ -9239,6 +9245,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"FilterArchitecturesDescription" : {
|
||||
|
||||
},
|
||||
"FilterAvailableDescription" : {
|
||||
"localizations" : {
|
||||
|
|
@ -13462,6 +13471,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Installed Only" : {
|
||||
|
||||
},
|
||||
"InstallHelper" : {
|
||||
"localizations" : {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import PackageDescription
|
|||
|
||||
let package = Package(
|
||||
name: "XcodesKit",
|
||||
platforms: [.macOS(.v11)],
|
||||
platforms: [.macOS(.v13)],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
|
|
|
|||
|
|
@ -35,8 +35,37 @@ public enum Architecture: String, Codable, Equatable, Hashable, Identifiable, Ca
|
|||
}
|
||||
}
|
||||
|
||||
public enum ArchitectureVariant: String, Codable, Equatable, Hashable, Identifiable, CaseIterable {
|
||||
public var id: Self { self }
|
||||
|
||||
case universal
|
||||
case appleSilicon
|
||||
|
||||
public var displayString: String {
|
||||
switch self {
|
||||
case .appleSilicon:
|
||||
return "Apple Silicon"
|
||||
case .universal:
|
||||
return "Universal"
|
||||
}
|
||||
}
|
||||
|
||||
public var iconName: String {
|
||||
switch self {
|
||||
case .appleSilicon:
|
||||
return "m4.button.horizontal"
|
||||
case .universal:
|
||||
return "cpu.fill"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Array where Element == Architecture {
|
||||
public var isAppleSilicon: Bool {
|
||||
self == [.arm64]
|
||||
}
|
||||
|
||||
public var isUniversal: Bool {
|
||||
self.contains([.arm64, .x86_64])
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue