This commit is contained in:
Alin
2024-06-26 12:39:48 -06:00
parent f6b0044bbf
commit a6dad3bb4f
4 changed files with 15 additions and 20 deletions
+3
View File
@@ -316,6 +316,8 @@ class AppPathFinder {
fileIcon[path] = getIconForFileOrFolderNS(atPath: path)
}
let arch = checkAppBundleArchitecture(at: self.appInfo.path.path)
DispatchQueue.main.async {
var updatedCollection = sortedCollection
if updatedCollection.count == 1, let firstURL = updatedCollection.first, firstURL.path.contains(".Trash") {
@@ -326,6 +328,7 @@ class AppPathFinder {
self.appInfo.fileSize = fileSize
self.appInfo.fileSizeLogical = fileSizeLogical
self.appInfo.fileIcon = fileIcon
self.appInfo.arch = arch
if !self.backgroundRun {
self.appState.appInfo = self.appInfo
+8 -8
View File
@@ -254,7 +254,6 @@ func isRestricted(atPath path: URL) -> Bool {
// Check app bundle architecture
func checkAppBundleArchitecture(at appBundlePath: String) -> Arch {
let bundleURL = URL(fileURLWithPath: appBundlePath)
let executableName: String
@@ -264,14 +263,15 @@ func checkAppBundleArchitecture(at appBundlePath: String) -> Arch {
let bundleExecutable = infoPlist["CFBundleExecutable"] as? String {
executableName = bundleExecutable
} else {
printOS("Failed to read Info.plist or CFBundleExecutable not found when checking bundle architecture")
return .empty
}
let executablePath = bundleURL.appendingPathComponent("Contents/MacOS/\(executableName)").path
let task = Process()
task.launchPath = "/usr/bin/lipo"
task.arguments = ["-archs", executablePath]
task.launchPath = "/usr/bin/file"
task.arguments = [executablePath]
let pipe = Pipe()
task.standardOutput = pipe
@@ -281,13 +281,13 @@ func checkAppBundleArchitecture(at appBundlePath: String) -> Arch {
task.waitUntilExit()
if let output = String(data: data, encoding: .utf8) {
let architectures = output.trimmingCharacters(in: .whitespacesAndNewlines).components(separatedBy: " ")
if architectures.contains("x86_64") && architectures.contains("arm64") {
if output.contains("Mach-O universal binary") {
return .universal
} else if architectures.contains("x86_64") {
return .intel
} else if architectures.contains("arm64") {
} else if output.contains("arm64") {
return .arm
} else if output.contains("x86_64") {
return .intel
}
}
-8
View File
@@ -137,14 +137,6 @@ struct AppListItems: View {
appState.sortedApps[index].bundleSize = size
}
}
let architecture = checkAppBundleArchitecture(at: appInfo.path.path)
updateOnMain {
// Optionally, update the appInfo in the appState array
if let index = appState.sortedApps.firstIndex(where: { $0.path == appInfo.path }) {
appState.sortedApps[index].arch = architecture
}
}
}
}