diff --git a/Pearcleaner.xcodeproj/project.pbxproj b/Pearcleaner.xcodeproj/project.pbxproj index a43a094..c7eb8fd 100644 --- a/Pearcleaner.xcodeproj/project.pbxproj +++ b/Pearcleaner.xcodeproj/project.pbxproj @@ -576,8 +576,8 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - APP_BUILD = 50; - APP_VERSION = 3.7.5; + APP_BUILD = 51; + APP_VERSION = 3.7.6; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -646,8 +646,8 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - APP_BUILD = 50; - APP_VERSION = 3.7.5; + APP_BUILD = 51; + APP_VERSION = 3.7.6; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; diff --git a/Pearcleaner/Logic/AppPathsFetch.swift b/Pearcleaner/Logic/AppPathsFetch.swift index 05f6330..9813d76 100644 --- a/Pearcleaner/Logic/AppPathsFetch.swift +++ b/Pearcleaner/Logic/AppPathsFetch.swift @@ -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 diff --git a/Pearcleaner/Logic/Utilities.swift b/Pearcleaner/Logic/Utilities.swift index 84ac9ab..df39717 100644 --- a/Pearcleaner/Logic/Utilities.swift +++ b/Pearcleaner/Logic/Utilities.swift @@ -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 } } diff --git a/Pearcleaner/Views/AppListItems.swift b/Pearcleaner/Views/AppListItems.swift index 4e3af14..1f9746d 100644 --- a/Pearcleaner/Views/AppListItems.swift +++ b/Pearcleaner/Views/AppListItems.swift @@ -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 - } - } } }