Free, open-source macOS cleaner. CleanMyMac alternative with zero telemetry. Native SwiftUI, scheduled auto-cleaning, Xcode/Homebrew/system cache cleanup. MIT licensed.
Swift cache-cleanercleanmymaccleanupdisk-cleanerdisk-spacehomebrewmac-utilitymacosmacos-appmacos-cleanermacosxnativeossosxprivacyswiftswiftuisystem-cleanerxcode-cleaner
Initial release of PureMac - free macOS cleaning utility
moamen7af6a8325ce1
diff --git a/.gitignore b/.gitignorenew file mode 100644index 0000000..8fd39a7--- /dev/null+++ b/.gitignore@@ -0,0 +1,30 @@+# Xcode+build/+DerivedData/+*.xcworkspace+!*.xcworkspace/contents.xcworkspacedata+*.xcuserdata+xcuserdata/++# macOS+.DS_Store+*.swp+*~++# Swift Package Manager+.build/+Packages/+Package.resolved++# CocoaPods+Pods/++# Carthage+Carthage/Build/++# IDE+*.pbxuser+*.mode1v3+*.mode2v3+*.perspectivev3+*.moved-asidediff --git a/LICENSE b/LICENSEnew file mode 100644index 0000000..c830c16--- /dev/null+++ b/LICENSE@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2026 PureMac Contributors++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/PureMac.xcodeproj/project.pbxproj b/PureMac.xcodeproj/project.pbxprojnew file mode 100644index 0000000..f22091c--- /dev/null+++ b/PureMac.xcodeproj/project.pbxproj@@ -0,0 +1,397 @@+// !$*UTF8*$!+{+ archiveVersion = 1;+ classes = {+ };+ objectVersion = 77;+ objects = {++/* Begin PBXBuildFile section */+ 015C7A8CE16D49F2C445C02A /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01E751C3B9ED986F1E6D3C8F /* SettingsView.swift */; };+ 0A7B70CBA747ED9FEE20C51A /* SidebarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5402892366B3F00417FD05F9 /* SidebarView.swift */; };+ 27F449EDD1B082FE11FEC9DF /* SchedulerService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28181F034530331A550C6A3D /* SchedulerService.swift */; };+ 340E424F759ACCDE7372F99F /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5ADDC35F31E40780FB5D017 /* Theme.swift */; };+ 48D1431A7C99C19EEBDB056B /* CleaningEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A8DE5D45BA19E2670B57DC5 /* CleaningEngine.swift */; };+ 826A750D2D7EC14C2AE306A3 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3667D46D8E2004EB4D73835A /* Models.swift */; };+ A221744A723582A6D075A7A0 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 86105573F4051764E9E46626 /* ContentView.swift */; };+ A89DF967EC9E5E8123B2925A /* SmartScanView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11BA091943263913276F3CCF /* SmartScanView.swift */; };+ B52938BBD11842631314543D /* CategoryDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 10B0AF194677EAC1D5568785 /* CategoryDetailView.swift */; };+ B8A524AF7F7DCDFCFCA9EDF6 /* AppViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD7FDA1B749FFA61DFB52AB5 /* AppViewModel.swift */; };+ D9445C2641A8637B65DA5ACE /* ScanEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = A711CDF5285F68775D9B5513 /* ScanEngine.swift */; };+ DDD6BA35DBF32E7A6B5F6F8B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B2EA41E1096FA8E3B916AD13 /* Assets.xcassets */; };+ EDEF28CAD23E936FBED1783B /* PureMacApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63581B70F9B10231964E3602 /* PureMacApp.swift */; };+/* End PBXBuildFile section */++/* Begin PBXFileReference section */+ 01E751C3B9ED986F1E6D3C8F /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };+ 10B0AF194677EAC1D5568785 /* CategoryDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryDetailView.swift; sourceTree = "<group>"; };+ 11BA091943263913276F3CCF /* SmartScanView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartScanView.swift; sourceTree = "<group>"; };+ 28181F034530331A550C6A3D /* SchedulerService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SchedulerService.swift; sourceTree = "<group>"; };+ 2A8DE5D45BA19E2670B57DC5 /* CleaningEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CleaningEngine.swift; sourceTree = "<group>"; };+ 311078221878708524283765 /* PureMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PureMac.app; sourceTree = BUILT_PRODUCTS_DIR; };+ 3667D46D8E2004EB4D73835A /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };+ 46660271CFF167AB0FE7371D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };+ 5402892366B3F00417FD05F9 /* SidebarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarView.swift; sourceTree = "<group>"; };+ 5664D2BDAEAA9AE3A53DB364 /* PureMac.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PureMac.entitlements; sourceTree = "<group>"; };+ 63581B70F9B10231964E3602 /* PureMacApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PureMacApp.swift; sourceTree = "<group>"; };+ 86105573F4051764E9E46626 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };+ A711CDF5285F68775D9B5513 /* ScanEngine.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanEngine.swift; sourceTree = "<group>"; };+ B2EA41E1096FA8E3B916AD13 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };+ C5ADDC35F31E40780FB5D017 /* Theme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Theme.swift; sourceTree = "<group>"; };+ DD7FDA1B749FFA61DFB52AB5 /* AppViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppViewModel.swift; sourceTree = "<group>"; };+/* End PBXFileReference section */++/* Begin PBXGroup section */+ 13CF0676D0E93925F46C13AA = {+ isa = PBXGroup;+ children = (+ E383F69184F4552E5A41D010 /* PureMac */,+ 4562CA9E5625FA4EEEFECB6D /* Products */,+ );+ sourceTree = "<group>";+ };+ 3CF46713F75B81F0F86D1C6F /* Models */ = {+ isa = PBXGroup;+ children = (+ 3667D46D8E2004EB4D73835A /* Models.swift */,+ );+ path = Models;+ sourceTree = "<group>";+ };+ 4562CA9E5625FA4EEEFECB6D /* Products */ = {+ isa = PBXGroup;+ children = (+ 311078221878708524283765 /* PureMac.app */,+ );+ name = Products;+ sourceTree = "<group>";+ };+ 45B485C4ACB5B08C1B87917F /* Views */ = {+ isa = PBXGroup;+ children = (+ 10B0AF194677EAC1D5568785 /* CategoryDetailView.swift */,+ 86105573F4051764E9E46626 /* ContentView.swift */,+ 01E751C3B9ED986F1E6D3C8F /* SettingsView.swift */,+ 5402892366B3F00417FD05F9 /* SidebarView.swift */,+ 11BA091943263913276F3CCF /* SmartScanView.swift */,+ );+ path = Views;+ sourceTree = "<group>";+ };+ 6184B2EC3D01E6E95633406E /* Services */ = {+ isa = PBXGroup;+ children = (+ 2A8DE5D45BA19E2670B57DC5 /* CleaningEngine.swift */,+ A711CDF5285F68775D9B5513 /* ScanEngine.swift */,+ 28181F034530331A550C6A3D /* SchedulerService.swift */,+ );+ path = Services;+ sourceTree = "<group>";+ };+ 7C1729F88C0E5563E1A3DB40 /* Extensions */ = {+ isa = PBXGroup;+ children = (+ C5ADDC35F31E40780FB5D017 /* Theme.swift */,+ );+ path = Extensions;+ sourceTree = "<group>";+ };+ A8F1C251567E5321E1CA2484 /* ViewModels */ = {+ isa = PBXGroup;+ children = (+ DD7FDA1B749FFA61DFB52AB5 /* AppViewModel.swift */,+ );+ path = ViewModels;+ sourceTree = "<group>";+ };+ E383F69184F4552E5A41D010 /* PureMac */ = {+ isa = PBXGroup;+ children = (+ B2EA41E1096FA8E3B916AD13 /* Assets.xcassets */,+ 46660271CFF167AB0FE7371D /* Info.plist */,+ 5664D2BDAEAA9AE3A53DB364 /* PureMac.entitlements */,+ 63581B70F9B10231964E3602 /* PureMacApp.swift */,+ 7C1729F88C0E5563E1A3DB40 /* Extensions */,+ 3CF46713F75B81F0F86D1C6F /* Models */,+ 6184B2EC3D01E6E95633406E /* Services */,+ A8F1C251567E5321E1CA2484 /* ViewModels */,+ 45B485C4ACB5B08C1B87917F /* Views */,+ );+ path = PureMac;+ sourceTree = "<group>";+ };+/* End PBXGroup section */++/* Begin PBXNativeTarget section */+ B19E38DEAA0144A77120F39C /* PureMac */ = {+ isa = PBXNativeTarget;+ buildConfigurationList = 2754925F163D15C85EDF494D /* Build configuration list for PBXNativeTarget "PureMac" */;+ buildPhases = (+ 63C589367B714FC06B0519E5 /* Sources */,+ 3975A867E04014FA565E9F46 /* Resources */,+ );+ buildRules = (+ );+ dependencies = (+ );+ name = PureMac;+ packageProductDependencies = (+ );+ productName = PureMac;+ productReference = 311078221878708524283765 /* PureMac.app */;+ productType = "com.apple.product-type.application";+ };+/* End PBXNativeTarget section */++/* Begin PBXProject section */+ 37BE87544E2EC9F6FF1CD280 /* Project object */ = {+ isa = PBXProject;+ attributes = {+ BuildIndependentTargetsInParallel = YES;+ LastUpgradeCheck = 1640;+ TargetAttributes = {+ };+ };+ buildConfigurationList = 2ABAFAE07AA42044AE58F688 /* Build configuration list for PBXProject "PureMac" */;+ developmentRegion = en;+ hasScannedForEncodings = 0;+ knownRegions = (+ Base,+ en,+ );+ mainGroup = 13CF0676D0E93925F46C13AA;+ minimizedProjectReferenceProxies = 1;+ preferredProjectObjectVersion = 77;+ productRefGroup = 4562CA9E5625FA4EEEFECB6D /* Products */;+ projectDirPath = "";+ projectRoot = "";+ targets = (+ B19E38DEAA0144A77120F39C /* PureMac */,+ );+ };+/* End PBXProject section */++/* Begin PBXResourcesBuildPhase section */+ 3975A867E04014FA565E9F46 /* Resources */ = {+ isa = PBXResourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ DDD6BA35DBF32E7A6B5F6F8B /* Assets.xcassets in Resources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+/* End PBXResourcesBuildPhase section */++/* Begin PBXSourcesBuildPhase section */+ 63C589367B714FC06B0519E5 /* Sources */ = {+ isa = PBXSourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ B8A524AF7F7DCDFCFCA9EDF6 /* AppViewModel.swift in Sources */,+ B52938BBD11842631314543D /* CategoryDetailView.swift in Sources */,+ 48D1431A7C99C19EEBDB056B /* CleaningEngine.swift in Sources */,+ A221744A723582A6D075A7A0 /* ContentView.swift in Sources */,+ 826A750D2D7EC14C2AE306A3 /* Models.swift in Sources */,+ EDEF28CAD23E936FBED1783B /* PureMacApp.swift in Sources */,+ D9445C2641A8637B65DA5ACE /* ScanEngine.swift in Sources */,+ 27F449EDD1B082FE11FEC9DF /* SchedulerService.swift in Sources */,+ 015C7A8CE16D49F2C445C02A /* SettingsView.swift in Sources */,+ 0A7B70CBA747ED9FEE20C51A /* SidebarView.swift in Sources */,+ A89DF967EC9E5E8123B2925A /* SmartScanView.swift in Sources */,+ 340E424F759ACCDE7372F99F /* Theme.swift in Sources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };+/* End PBXSourcesBuildPhase section */++/* Begin XCBuildConfiguration section */+ 0794DC5454CB748EC1374422 /* Debug */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ALWAYS_SEARCH_USER_PATHS = NO;+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CLANG_ANALYZER_NONNULL = YES;+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";+ CLANG_CXX_LIBRARY = "libc++";+ CLANG_ENABLE_MODULES = YES;+ CLANG_ENABLE_OBJC_ARC = YES;+ CLANG_ENABLE_OBJC_WEAK = YES;+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;+ CLANG_WARN_BOOL_CONVERSION = YES;+ CLANG_WARN_COMMA = YES;+ CLANG_WARN_CONSTANT_CONVERSION = YES;+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;+ CLANG_WARN_EMPTY_BODY = YES;+ CLANG_WARN_ENUM_CONVERSION = YES;+ CLANG_WARN_INFINITE_RECURSION = YES;+ CLANG_WARN_INT_CONVERSION = YES;+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;+ CLANG_WARN_STRICT_PROTOTYPES = YES;+ CLANG_WARN_SUSPICIOUS_MOVE = YES;+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;+ CLANG_WARN_UNREACHABLE_CODE = YES;+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;+ CODE_SIGNING_REQUIRED = NO;+ CODE_SIGN_ENTITLEMENTS = PureMac/PureMac.entitlements;+ CODE_SIGN_IDENTITY = "-";+ COMBINE_HIDPI_IMAGES = YES;+ COPY_PHASE_STRIP = NO;+ CURRENT_PROJECT_VERSION = 1;+ DEBUG_INFORMATION_FORMAT = dwarf;+ ENABLE_STRICT_OBJC_MSGSEND = YES;+ ENABLE_TESTABILITY = YES;+ GCC_C_LANGUAGE_STANDARD = gnu11;+ GCC_DYNAMIC_NO_PIC = NO;+ GCC_NO_COMMON_BLOCKS = YES;+ GCC_OPTIMIZATION_LEVEL = 0;+ GCC_PREPROCESSOR_DEFINITIONS = (+ "$(inherited)",+ "DEBUG=1",+ );+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;+ GCC_WARN_UNDECLARED_SELECTOR = YES;+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;+ GCC_WARN_UNUSED_FUNCTION = YES;+ GCC_WARN_UNUSED_VARIABLE = YES;+ GENERATE_INFOPLIST_FILE = NO;+ INFOPLIST_FILE = PureMac/Info.plist;+ MACOSX_DEPLOYMENT_TARGET = 13.0;+ MARKETING_VERSION = 1.0.0;+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;+ MTL_FAST_MATH = YES;+ ONLY_ACTIVE_ARCH = YES;+ PRODUCT_BUNDLE_IDENTIFIER = com.puremac.app;+ PRODUCT_NAME = "$(TARGET_NAME)";+ SDKROOT = macosx;+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";+ SWIFT_VERSION = 5.9;+ };+ name = Debug;+ };+ 62DEA95205CFC6624F5AE4DA /* Debug */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ COMBINE_HIDPI_IMAGES = YES;+ INFOPLIST_FILE = PureMac/Info.plist;+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";+ PRODUCT_NAME = PureMac;+ SDKROOT = macosx;+ SWIFT_EMIT_LOC_STRINGS = YES;+ };+ name = Debug;+ };+ D1B9D379DD6CC0DA24E58BCF /* Release */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ALWAYS_SEARCH_USER_PATHS = NO;+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CLANG_ANALYZER_NONNULL = YES;+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";+ CLANG_CXX_LIBRARY = "libc++";+ CLANG_ENABLE_MODULES = YES;+ CLANG_ENABLE_OBJC_ARC = YES;+ CLANG_ENABLE_OBJC_WEAK = YES;+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;+ CLANG_WARN_BOOL_CONVERSION = YES;+ CLANG_WARN_COMMA = YES;+ CLANG_WARN_CONSTANT_CONVERSION = YES;+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;+ CLANG_WARN_EMPTY_BODY = YES;+ CLANG_WARN_ENUM_CONVERSION = YES;+ CLANG_WARN_INFINITE_RECURSION = YES;+ CLANG_WARN_INT_CONVERSION = YES;+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;+ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;+ CLANG_WARN_STRICT_PROTOTYPES = YES;+ CLANG_WARN_SUSPICIOUS_MOVE = YES;+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;+ CLANG_WARN_UNREACHABLE_CODE = YES;+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;+ CODE_SIGNING_REQUIRED = NO;+ CODE_SIGN_ENTITLEMENTS = PureMac/PureMac.entitlements;+ CODE_SIGN_IDENTITY = "-";+ COMBINE_HIDPI_IMAGES = YES;+ COPY_PHASE_STRIP = NO;+ CURRENT_PROJECT_VERSION = 1;+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";+ ENABLE_NS_ASSERTIONS = NO;+ ENABLE_STRICT_OBJC_MSGSEND = YES;+ GCC_C_LANGUAGE_STANDARD = gnu11;+ GCC_NO_COMMON_BLOCKS = YES;+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;+ GCC_WARN_UNDECLARED_SELECTOR = YES;+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;+ GCC_WARN_UNUSED_FUNCTION = YES;+ GCC_WARN_UNUSED_VARIABLE = YES;+ GENERATE_INFOPLIST_FILE = NO;+ INFOPLIST_FILE = PureMac/Info.plist;+ MACOSX_DEPLOYMENT_TARGET = 13.0;+ MARKETING_VERSION = 1.0.0;+ MTL_ENABLE_DEBUG_INFO = NO;+ MTL_FAST_MATH = YES;+ PRODUCT_BUNDLE_IDENTIFIER = com.puremac.app;+ PRODUCT_NAME = "$(TARGET_NAME)";+ SDKROOT = macosx;+ SWIFT_COMPILATION_MODE = wholemodule;+ SWIFT_OPTIMIZATION_LEVEL = "-O";+ SWIFT_VERSION = 5.9;+ };+ name = Release;+ };+ F079CEBA12A56241A5D0D3BC /* Release */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ COMBINE_HIDPI_IMAGES = YES;+ INFOPLIST_FILE = PureMac/Info.plist;+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";+ PRODUCT_NAME = PureMac;+ SDKROOT = macosx;+ SWIFT_EMIT_LOC_STRINGS = YES;+ };+ name = Release;+ };+/* End XCBuildConfiguration section */++/* Begin XCConfigurationList section */+ 2754925F163D15C85EDF494D /* Build configuration list for PBXNativeTarget "PureMac" */ = {+ isa = XCConfigurationList;+ buildConfigurations = (+ 62DEA95205CFC6624F5AE4DA /* Debug */,+ F079CEBA12A56241A5D0D3BC /* Release */,+ );+ defaultConfigurationIsVisible = 0;+ defaultConfigurationName = Release;+ };+ 2ABAFAE07AA42044AE58F688 /* Build configuration list for PBXProject "PureMac" */ = {+ isa = XCConfigurationList;+ buildConfigurations = (+ 0794DC5454CB748EC1374422 /* Debug */,+ D1B9D379DD6CC0DA24E58BCF /* Release */,+ );+ defaultConfigurationIsVisible = 0;+ defaultConfigurationName = Release;+ };+/* End XCConfigurationList section */+ };+ rootObject = 37BE87544E2EC9F6FF1CD280 /* Project object */;+}diff --git a/PureMac/Assets.xcassets/AccentColor.colorset/Contents.json b/PureMac/Assets.xcassets/AccentColor.colorset/Contents.jsonnew file mode 100644index 0000000..8603fbe--- /dev/null+++ b/PureMac/Assets.xcassets/AccentColor.colorset/Contents.json@@ -0,0 +1,20 @@+{+ "colors" : [+ {+ "color" : {+ "color-space" : "srgb",+ "components" : {+ "alpha" : "1.000",+ "blue" : "0.945",+ "green" : "0.400",+ "red" : "0.388"+ }+ },+ "idiom" : "universal"+ }+ ],+ "info" : {+ "author" : "xcode",+ "version" : 1+ }+}diff --git a/PureMac/Assets.xcassets/AppIcon.appiconset/Contents.json b/PureMac/Assets.xcassets/AppIcon.appiconset/Contents.jsonnew file mode 100644index 0000000..3f00db4--- /dev/null+++ b/PureMac/Assets.xcassets/AppIcon.appiconset/Contents.json@@ -0,0 +1,58 @@+{+ "images" : [+ {+ "idiom" : "mac",+ "scale" : "1x",+ "size" : "16x16"+ },+ {+ "idiom" : "mac",+ "scale" : "2x",+ "size" : "16x16"+ },+ {+ "idiom" : "mac",+ "scale" : "1x",+ "size" : "32x32"+ },+ {+ "idiom" : "mac",+ "scale" : "2x",+ "size" : "32x32"+ },+ {+ "idiom" : "mac",+ "scale" : "1x",+ "size" : "128x128"+ },+ {+ "idiom" : "mac",+ "scale" : "2x",+ "size" : "128x128"+ },+ {+ "idiom" : "mac",+ "scale" : "1x",+ "size" : "256x256"+ },+ {+ "idiom" : "mac",+ "scale" : "2x",+ "size" : "256x256"+ },+ {+ "idiom" : "mac",+ "scale" : "1x",+ "size" : "512x512"+ },+ {+ "idiom" : "mac",+ "scale" : "2x",+ "size" : "512x512"+ }+ ],+ "info" : {+ "author" : "xcode",+ "version" : 1+ }+}diff --git a/PureMac/Assets.xcassets/Contents.json b/PureMac/Assets.xcassets/Contents.jsonnew file mode 100644index 0000000..73c0059--- /dev/null+++ b/PureMac/Assets.xcassets/Contents.json@@ -0,0 +1,6 @@+{+ "info" : {+ "author" : "xcode",+ "version" : 1+ }+}diff --git a/PureMac/Extensions/Theme.swift b/PureMac/Extensions/Theme.swiftnew file mode 100644index 0000000..544589e--- /dev/null+++ b/PureMac/Extensions/Theme.swift@@ -0,0 +1,134 @@+import SwiftUI++// MARK: - Color Theme++extension Color {+ // Background colors+ static let pmBackground = Color(hex: "0f0f1a")+ static let pmSidebar = Color(hex: "161627")+ static let pmCard = Color(hex: "1c1c35")+ static let pmCardHover = Color(hex: "252545")++ // Accent colors+ static let pmAccent = Color(hex: "6366f1")+ static let pmAccentLight = Color(hex: "818cf8")+ static let pmAccentDark = Color(hex: "4f46e5")++ // Gradient colors+ static let pmGradientStart = Color(hex: "6366f1")+ static let pmGradientEnd = Color(hex: "a855f7")+ static let pmGradientAlt = Color(hex: "ec4899")++ // Status colors+ static let pmSuccess = Color(hex: "10b981")+ static let pmWarning = Color(hex: "f59e0b")+ static let pmDanger = Color(hex: "ef4444")+ static let pmInfo = Color(hex: "3b82f6")++ // Text colors+ static let pmTextPrimary = Color(hex: "f1f5f9")+ static let pmTextSecondary = Color(hex: "94a3b8")+ static let pmTextMuted = Color(hex: "64748b")++ // Separator+ static let pmSeparator = Color(hex: "2d2d50")++ init(hex: String) {+ let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)+ var int: UInt64 = 0+ Scanner(string: hex).scanHexInt64(&int)+ let a, r, g, b: UInt64+ switch hex.count {+ case 6:+ (a, r, g, b) = (255, (int >> 16) & 0xFF, (int >> 8) & 0xFF, int & 0xFF)+ case 8:+ (a, r, g, b) = ((int >> 24) & 0xFF, (int >> 16) & 0xFF, (int >> 8) & 0xFF, int & 0xFF)+ default:+ (a, r, g, b) = (255, 0, 0, 0)+ }+ self.init(+ .sRGB,+ red: Double(r) / 255,+ green: Double(g) / 255,+ blue: Double(b) / 255,+ opacity: Double(a) / 255+ )+ }+}++// MARK: - Gradients++struct AppGradients {+ static let primary = LinearGradient(+ colors: [.pmGradientStart, .pmGradientEnd],+ startPoint: .topLeading,+ endPoint: .bottomTrailing+ )++ static let accent = LinearGradient(+ colors: [.pmAccent, .pmGradientEnd],+ startPoint: .leading,+ endPoint: .trailing+ )++ static let danger = LinearGradient(+ colors: [.pmDanger, Color(hex: "dc2626")],+ startPoint: .leading,+ endPoint: .trailing+ )++ static let success = LinearGradient(+ colors: [.pmSuccess, Color(hex: "059669")],+ startPoint: .leading,+ endPoint: .trailing+ )++ static let background = LinearGradient(+ colors: [Color(hex: "0f0f1a"), Color(hex: "1a1a2e")],+ startPoint: .top,+ endPoint: .bottom+ )++ static let sidebar = LinearGradient(+ colors: [Color(hex: "131325"), Color(hex: "1a1a35")],+ startPoint: .top,+ endPoint: .bottom+ )++ static let scanRing = AngularGradient(+ colors: [.pmGradientStart, .pmGradientEnd, .pmGradientAlt, .pmGradientStart],+ center: .center+ )+}++// MARK: - Shadows++extension View {+ func pmShadow(radius: CGFloat = 10, y: CGFloat = 4) -> some View {+ self.shadow(color: .black.opacity(0.3), radius: radius, x: 0, y: y)+ }++ func pmGlow(color: Color = .pmAccent, radius: CGFloat = 20) -> some View {+ self.shadow(color: color.opacity(0.3), radius: radius, x: 0, y: 0)+ }+}++// MARK: - Text Styles++extension Font {+ static let pmTitle = Font.system(size: 28, weight: .bold, design: .rounded)+ static let pmHeadline = Font.system(size: 20, weight: .semibold, design: .rounded)+ static let pmSubheadline = Font.system(size: 16, weight: .medium, design: .rounded)+ static let pmBody = Font.system(size: 14, weight: .regular, design: .rounded)+ static let pmCaption = Font.system(size: 12, weight: .medium, design: .rounded)+ static let pmLargeNumber = Font.system(size: 42, weight: .bold, design: .rounded)+ static let pmMediumNumber = Font.system(size: 24, weight: .bold, design: .rounded)+}++// MARK: - Animation++extension Animation {+ static let pmSpring = Animation.spring(response: 0.5, dampingFraction: 0.8, blendDuration: 0)+ static let pmSmooth = Animation.easeInOut(duration: 0.3)+ static let pmSlow = Animation.easeInOut(duration: 0.6)+}diff --git a/PureMac/Info.plist b/PureMac/Info.plistnew file mode 100644index 0000000..d48d1c7--- /dev/null+++ b/PureMac/Info.plist@@ -0,0 +1,28 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>CFBundleDevelopmentRegion</key>+ <string>en</string>+ <key>CFBundleExecutable</key>+ <string>$(EXECUTABLE_NAME)</string>+ <key>CFBundleIdentifier</key>+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>+ <key>CFBundleName</key>+ <string>PureMac</string>+ <key>CFBundleDisplayName</key>+ <string>PureMac</string>+ <key>CFBundlePackageType</key>+ <string>APPL</string>+ <key>CFBundleShortVersionString</key>+ <string>1.0.0</string>+ <key>CFBundleVersion</key>+ <string>1</string>+ <key>LSMinimumSystemVersion</key>+ <string>$(MACOSX_DEPLOYMENT_TARGET)</string>+ <key>LSApplicationCategoryType</key>+ <string>public.app-category.utilities</string>+ <key>NSHumanReadableCopyright</key>+ <string>Copyright 2026. MIT License.</string>+</dict>+</plist>diff --git a/PureMac/Models/Models.swift b/PureMac/Models/Models.swiftnew file mode 100644index 0000000..28f6dde--- /dev/null+++ b/PureMac/Models/Models.swift@@ -0,0 +1,209 @@+import SwiftUI++// MARK: - Cleaning Category++enum CleaningCategory: String, CaseIterable, Identifiable, Codable {+ case smartScan = "Smart Scan"+ case systemJunk = "System Junk"+ case userCache = "User Cache"+ case mailAttachments = "Mail Attachments"+ case trashBins = "Trash Bins"+ case largeFiles = "Large & Old Files"+ case purgeableSpace = "Purgeable Space"+ case xcodeJunk = "Xcode Junk"+ case brewCache = "Homebrew Cache"++ var id: String { rawValue }++ var icon: String {+ switch self {+ case .smartScan: return "sparkles"+ case .systemJunk: return "gearshape.fill"+ case .userCache: return "internaldrive.fill"+ case .mailAttachments: return "envelope.fill"+ case .trashBins: return "trash.fill"+ case .largeFiles: return "doc.fill"+ case .purgeableSpace: return "arrow.3.trianglepath"+ case .xcodeJunk: return "hammer.fill"+ case .brewCache: return "mug.fill"+ }+ }++ var description: String {+ switch self {+ case .smartScan: return "Scan everything at once"+ case .systemJunk: return "System caches, logs, and temporary files"+ case .userCache: return "Application caches and browser data"+ case .mailAttachments: return "Downloaded mail attachments"+ case .trashBins: return "Files in your Trash"+ case .largeFiles: return "Files over 100 MB or older than 1 year"+ case .purgeableSpace: return "APFS purgeable disk space"+ case .xcodeJunk: return "Derived data, archives, and simulators"+ case .brewCache: return "Homebrew download cache"+ }+ }++ var color: Color {+ switch self {+ case .smartScan: return .pmAccent+ case .systemJunk: return .pmGradientEnd+ case .userCache: return .pmInfo+ case .mailAttachments: return .pmWarning+ case .trashBins: return .pmDanger+ case .largeFiles: return Color(hex: "f97316")+ case .purgeableSpace: return .pmSuccess+ case .xcodeJunk: return Color(hex: "06b6d4")+ case .brewCache: return Color(hex: "84cc16")+ }+ }++ // Categories to scan in Smart Scan mode+ static var scannable: [CleaningCategory] {+ allCases.filter { $0 != .smartScan }+ }+}++// MARK: - Scan State++enum ScanState: Equatable {+ case idle+ case scanning(progress: Double, currentCategory: String)+ case completed+ case cleaning(progress: Double)+ case cleaned++ var isActive: Bool {+ switch self {+ case .scanning, .cleaning: return true+ default: return false+ }+ }+}++// MARK: - Cleanable Item++struct CleanableItem: Identifiable, Hashable {+ let id = UUID()+ let name: String+ let path: String+ let size: Int64+ let category: CleaningCategory+ let isSelected: Bool+ let lastModified: Date?++ var formattedSize: String {+ ByteCountFormatter.string(fromByteCount: size, countStyle: .file)+ }++ func hash(into hasher: inout Hasher) {+ hasher.combine(id)+ }++ static func == (lhs: CleanableItem, rhs: CleanableItem) -> Bool {+ lhs.id == rhs.id+ }+}++// MARK: - Category Result++struct CategoryResult: Identifiable {+ let id = UUID()+ let category: CleaningCategory+ var items: [CleanableItem]+ var totalSize: Int64++ var formattedSize: String {+ ByteCountFormatter.string(fromByteCount: totalSize, countStyle: .file)+ }++ var itemCount: Int { items.count }+}++// MARK: - Schedule Settings++enum ScheduleInterval: String, CaseIterable, Identifiable, Codable {+ case hours1 = "Every Hour"+ case hours3 = "Every 3 Hours"+ case hours6 = "Every 6 Hours"+ case hours12 = "Every 12 Hours"+ case daily = "Daily"+ case weekly = "Weekly"+ case biweekly = "Every 2 Weeks"+ case monthly = "Monthly"++ var id: String { rawValue }++ var seconds: TimeInterval {+ switch self {+ case .hours1: return 3600+ case .hours3: return 10800+ case .hours6: return 21600+ case .hours12: return 43200+ case .daily: return 86400+ case .weekly: return 604800+ case .biweekly: return 1209600+ case .monthly: return 2592000+ }+ }+}++struct ScheduleConfig: Codable {+ var isEnabled: Bool = false+ var interval: ScheduleInterval = .daily+ var autoClean: Bool = false+ var autoPurge: Bool = false+ var categoriesToScan: [CleaningCategory] = CleaningCategory.scannable+ var lastRunDate: Date?+ var nextRunDate: Date?+ var notifyOnCompletion: Bool = true+ var minimumCleanSize: Int64 = 100 * 1024 * 1024 // 100 MB++ var formattedLastRun: String {+ guard let date = lastRunDate else { return "Never" }+ let formatter = RelativeDateTimeFormatter()+ formatter.unitsStyle = .abbreviated+ return formatter.localizedString(for: date, relativeTo: Date())+ }++ var formattedNextRun: String {+ guard let date = nextRunDate else { return "Not scheduled" }+ let formatter = RelativeDateTimeFormatter()+ formatter.unitsStyle = .abbreviated+ return formatter.localizedString(for: date, relativeTo: Date())+ }+}++// MARK: - Disk Info++struct DiskInfo {+ var totalSpace: Int64 = 0+ var freeSpace: Int64 = 0+ var usedSpace: Int64 = 0+ var purgeableSpace: Int64 = 0++ var usedPercentage: Double {+ guard totalSpace > 0 else { return 0 }+ return Double(usedSpace) / Double(totalSpace)+ }++ var freePercentage: Double {+ guard totalSpace > 0 else { return 0 }+ return Double(freeSpace) / Double(totalSpace)+ }++ var formattedTotal: String {+ ByteCountFormatter.string(fromByteCount: totalSpace, countStyle: .file)+ }++ var formattedFree: String {+ ByteCountFormatter.string(fromByteCount: freeSpace, countStyle: .file)+ }++ var formattedUsed: String {+ ByteCountFormatter.string(fromByteCount: usedSpace, countStyle: .file)+ }++ var formattedPurgeable: String {+ ByteCountFormatter.string(fromByteCount: purgeableSpace, countStyle: .file)+ }+}diff --git a/PureMac/PureMac.entitlements b/PureMac/PureMac.entitlementsnew file mode 100644index 0000000..bdf7f8c--- /dev/null+++ b/PureMac/PureMac.entitlements@@ -0,0 +1,12 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.security.app-sandbox</key>+ <false/>+ <key>com.apple.security.files.user-selected.read-write</key>+ <true/>+ <key>com.apple.security.files.downloads.read-write</key>+ <true/>+</dict>+</plist>diff --git a/PureMac/PureMacApp.swift b/PureMac/PureMacApp.swiftnew file mode 100644index 0000000..0b3c5ee--- /dev/null+++ b/PureMac/PureMacApp.swift@@ -0,0 +1,25 @@+import SwiftUI++@main+struct PureMacApp: App {+ @StateObject private var appViewModel = AppViewModel()++ var body: some Scene {+ WindowGroup {+ ContentView()+ .environmentObject(appViewModel)+ .frame(minWidth: 900, minHeight: 600)+ .preferredColorScheme(.dark)+ }+ .windowStyle(.hiddenTitleBar)+ .defaultSize(width: 1000, height: 680)+ .commands {+ CommandGroup(replacing: .newItem) {}+ }++ Settings {+ SettingsView()+ .environmentObject(appViewModel)+ }+ }+}diff --git a/PureMac/Services/CleaningEngine.swift b/PureMac/Services/CleaningEngine.swiftnew file mode 100644index 0000000..6022abd--- /dev/null+++ b/PureMac/Services/CleaningEngine.swift@@ -0,0 +1,106 @@+import Foundation++actor CleaningEngine {+ private let fileManager = FileManager.default++ struct CleaningResult {+ var freedSpace: Int64 = 0+ var itemsCleaned: Int = 0+ var errors: [String] = []+ }++ // MARK: - Public API++ func cleanItems(_ items: [CleanableItem], progressHandler: @Sendable (Double) -> Void) async -> CleaningResult {+ var result = CleaningResult()+ let total = items.count++ for (index, item) in items.enumerated() {+ let progress = Double(index + 1) / Double(total)+ progressHandler(progress)++ if item.category == .purgeableSpace {+ let purged = await purgePurgeableSpace()+ result.freedSpace += purged+ if purged > 0 { result.itemsCleaned += 1 }+ continue+ }++ do {+ if fileManager.fileExists(atPath: item.path) {+ try fileManager.removeItem(atPath: item.path)+ result.freedSpace += item.size+ result.itemsCleaned += 1+ }+ } catch {+ result.errors.append("\(item.name): \(error.localizedDescription)")+ }+ }++ return result+ }++ func cleanCategory(_ result: CategoryResult, progressHandler: @Sendable (Double) -> Void) async -> CleaningResult {+ let selectedItems = result.items.filter { $0.isSelected }+ return await cleanItems(selectedItems, progressHandler: progressHandler)+ }++ // MARK: - Purgeable Space++ func purgePurgeableSpace() async -> Int64 {+ // Get current purgeable space first+ let beforeFree = getCurrentFreeSpace()++ let task = Process()+ task.executableURL = URL(fileURLWithPath: "/usr/sbin/diskutil")+ task.arguments = ["apfs", "purgePurgeable", "/"]+ let pipe = Pipe()+ task.standardOutput = pipe+ task.standardError = Pipe()++ do {+ try task.run()+ task.waitUntilExit()++ let afterFree = getCurrentFreeSpace()+ let freedSpace = afterFree - beforeFree+ return max(0, freedSpace)+ } catch {+ return 0+ }+ }++ // MARK: - Trash++ func emptyTrash() async -> Int64 {+ let home = fileManager.homeDirectoryForCurrentUser.path+ let trashPath = "\(home)/.Trash"+ var totalFreed: Int64 = 0++ do {+ let contents = try fileManager.contentsOfDirectory(atPath: trashPath)+ for item in contents {+ let fullPath = (trashPath as NSString).appendingPathComponent(item)+ if let attrs = try? fileManager.attributesOfItem(atPath: fullPath) {+ totalFreed += (attrs[.size] as? Int64) ?? 0+ }+ try fileManager.removeItem(atPath: fullPath)+ }+ } catch {+ // Partial cleanup is OK+ }++ return totalFreed+ }++ // MARK: - Helpers++ private func getCurrentFreeSpace() -> Int64 {+ do {+ let attrs = try fileManager.attributesOfFileSystem(forPath: "/")+ return (attrs[.systemFreeSize] as? Int64) ?? 0+ } catch {+ return 0+ }+ }+}diff --git a/PureMac/Services/ScanEngine.swift b/PureMac/Services/ScanEngine.swiftnew file mode 100644index 0000000..938e430--- /dev/null+++ b/PureMac/Services/ScanEngine.swift@@ -0,0 +1,375 @@+import Foundation++actor ScanEngine {+ private let fileManager = FileManager.default+ private let home = FileManager.default.homeDirectoryForCurrentUser.path++ // MARK: - Public API++ func scanCategory(_ category: CleaningCategory) async -> CategoryResult {+ switch category {+ case .smartScan:+ return CategoryResult(category: category, items: [], totalSize: 0)+ case .systemJunk:+ return await scanSystemJunk()+ case .userCache:+ return await scanUserCache()+ case .mailAttachments:+ return await scanMailAttachments()+ case .trashBins:+ return await scanTrash()+ case .largeFiles:+ return await scanLargeFiles()+ case .purgeableSpace:+ return await scanPurgeableSpace()+ case .xcodeJunk:+ return await scanXcodeJunk()+ case .brewCache:+ return await scanBrewCache()+ }+ }++ func getDiskInfo() -> DiskInfo {+ var info = DiskInfo()+ do {+ let attrs = try fileManager.attributesOfFileSystem(forPath: "/")+ if let total = attrs[.systemSize] as? Int64 {+ info.totalSpace = total+ }+ if let free = attrs[.systemFreeSize] as? Int64 {+ info.freeSpace = free+ }+ info.usedSpace = info.totalSpace - info.freeSpace++ // Get purgeable space via diskutil+ let task = Process()+ task.executableURL = URL(fileURLWithPath: "/usr/sbin/diskutil")+ task.arguments = ["info", "/"]+ let pipe = Pipe()+ task.standardOutput = pipe+ task.standardError = Pipe()+ try task.run()+ task.waitUntilExit()+ let data = pipe.fileHandleForReading.readDataToEndOfFile()+ if let output = String(data: data, encoding: .utf8) {+ for line in output.components(separatedBy: "\n") {+ if line.contains("Purgeable") || line.contains("Container Free Space") {+ let parts = line.components(separatedBy: "(")+ if parts.count > 1 {+ let bytesStr = parts[1]+ .components(separatedBy: " Bytes")[0]+ .trimmingCharacters(in: .whitespaces)+ if let bytes = Int64(bytesStr) {+ info.purgeableSpace = bytes+ }+ }+ }+ }+ }+ } catch {+ // Silently fail - disk info is supplementary+ }+ return info+ }++ // MARK: - Scanners++ private func scanSystemJunk() async -> CategoryResult {+ var items: [CleanableItem] = []+ var totalSize: Int64 = 0++ let systemPaths = [+ "/Library/Caches",+ "/Library/Logs",+ "/private/var/log",+ "\(home)/Library/Logs",+ "/tmp",+ "/private/var/tmp",+ ]++ for path in systemPaths {+ let scanned = scanDirectory(path: path, category: .systemJunk, recursive: true, maxDepth: 3)+ items.append(contentsOf: scanned)+ }++ totalSize = items.reduce(0) { $0 + $1.size }+ return CategoryResult(category: .systemJunk, items: items, totalSize: totalSize)+ }++ private func scanUserCache() async -> CategoryResult {+ var items: [CleanableItem] = []++ let cachePaths = [+ "\(home)/Library/Caches",+ "\(home)/Library/Caches/com.apple.Safari",+ "\(home)/Library/Caches/Google/Chrome",+ "\(home)/Library/Caches/Firefox",+ "\(home)/Library/Caches/com.spotify.client",+ "\(home)/Library/Caches/com.microsoft.VSCode",+ "\(home)/Library/Caches/Slack",+ ]++ for path in cachePaths {+ let scanned = scanDirectory(path: path, category: .userCache, recursive: false, maxDepth: 1)+ items.append(contentsOf: scanned)+ }++ // Also scan for npm/pip/yarn caches+ let devCaches = [+ "\(home)/.npm/_cacache",+ "\(home)/.cache/pip",+ "\(home)/.cache/yarn",+ "\(home)/.cache/pnpm",+ "\(home)/Library/Caches/pip",+ ]++ for path in devCaches {+ if fileManager.fileExists(atPath: path) {+ let size = directorySize(path: path)+ if size > 0 {+ items.append(CleanableItem(+ name: URL(fileURLWithPath: path).lastPathComponent,+ path: path,+ size: size,+ category: .userCache,+ isSelected: true,+ lastModified: nil+ ))+ }+ }+ }++ let totalSize = items.reduce(0) { $0 + $1.size }+ return CategoryResult(category: .userCache, items: items, totalSize: totalSize)+ }++ private func scanMailAttachments() async -> CategoryResult {+ var items: [CleanableItem] = []++ let mailPaths = [+ "\(home)/Library/Mail Downloads",+ "\(home)/Library/Containers/com.apple.mail/Data/Library/Mail Downloads",+ ]++ for path in mailPaths {+ let scanned = scanDirectory(path: path, category: .mailAttachments, recursive: true, maxDepth: 3)+ items.append(contentsOf: scanned)+ }++ let totalSize = items.reduce(0) { $0 + $1.size }+ return CategoryResult(category: .mailAttachments, items: items, totalSize: totalSize)+ }++ private func scanTrash() async -> CategoryResult {+ var items: [CleanableItem] = []++ let trashPath = "\(home)/.Trash"+ let scanned = scanDirectory(path: trashPath, category: .trashBins, recursive: false, maxDepth: 1)+ items.append(contentsOf: scanned)++ let totalSize = items.reduce(0) { $0 + $1.size }+ return CategoryResult(category: .trashBins, items: items, totalSize: totalSize)+ }++ private func scanLargeFiles() async -> CategoryResult {+ var items: [CleanableItem] = []+ let minSize: Int64 = 100 * 1024 * 1024 // 100 MB+ let oneYearAgo = Calendar.current.date(byAdding: .year, value: -1, to: Date())!++ let searchPaths = [+ "\(home)/Downloads",+ "\(home)/Documents",+ "\(home)/Desktop",+ ]++ for basePath in searchPaths {+ guard let enumerator = fileManager.enumerator(+ at: URL(fileURLWithPath: basePath),+ includingPropertiesForKeys: [.fileSizeKey, .contentModificationDateKey, .isRegularFileKey],+ options: [.skipsHiddenFiles, .skipsPackageDescendants]+ ) else { continue }++ var depth = 0+ for case let fileURL as URL in enumerator {+ depth += 1+ if depth > 5000 { break } // Safety limit++ guard let resourceValues = try? fileURL.resourceValues(forKeys: [.fileSizeKey, .contentModificationDateKey, .isRegularFileKey]),+ let isFile = resourceValues.isRegularFile, isFile,+ let fileSize = resourceValues.fileSize+ else { continue }++ let size = Int64(fileSize)+ let modDate = resourceValues.contentModificationDate++ if size > minSize || (modDate != nil && modDate! < oneYearAgo && size > 10 * 1024 * 1024) {+ items.append(CleanableItem(+ name: fileURL.lastPathComponent,+ path: fileURL.path,+ size: size,+ category: .largeFiles,+ isSelected: false, // Don't auto-select large files+ lastModified: modDate+ ))+ }+ }+ }++ items.sort { $0.size > $1.size }+ let totalSize = items.reduce(0) { $0 + $1.size }+ return CategoryResult(category: .largeFiles, items: items, totalSize: totalSize)+ }++ private func scanPurgeableSpace() async -> CategoryResult {+ let diskInfo = getDiskInfo()+ var items: [CleanableItem] = []++ if diskInfo.purgeableSpace > 0 {+ items.append(CleanableItem(+ name: "APFS Purgeable Space",+ path: "/",+ size: diskInfo.purgeableSpace,+ category: .purgeableSpace,+ isSelected: true,+ lastModified: nil+ ))+ }++ return CategoryResult(category: .purgeableSpace, items: items, totalSize: diskInfo.purgeableSpace)+ }++ private func scanXcodeJunk() async -> CategoryResult {+ var items: [CleanableItem] = []++ let xcodePaths = [+ "\(home)/Library/Developer/Xcode/DerivedData",+ "\(home)/Library/Developer/Xcode/Archives",+ "\(home)/Library/Developer/CoreSimulator/Caches",+ "\(home)/Library/Caches/com.apple.dt.Xcode",+ ]++ for path in xcodePaths {+ if fileManager.fileExists(atPath: path) {+ let size = directorySize(path: path)+ if size > 0 {+ items.append(CleanableItem(+ name: URL(fileURLWithPath: path).lastPathComponent,+ path: path,+ size: size,+ category: .xcodeJunk,+ isSelected: true,+ lastModified: nil+ ))+ }+ }+ }++ let totalSize = items.reduce(0) { $0 + $1.size }+ return CategoryResult(category: .xcodeJunk, items: items, totalSize: totalSize)+ }++ private func scanBrewCache() async -> CategoryResult {+ var items: [CleanableItem] = []++ // Homebrew cache location+ let brewCachePaths = [+ "\(home)/Library/Caches/Homebrew",+ "/opt/homebrew/Caskroom/.metadata",+ ]++ for path in brewCachePaths {+ if fileManager.fileExists(atPath: path) {+ let size = directorySize(path: path)+ if size > 0 {+ items.append(CleanableItem(+ name: URL(fileURLWithPath: path).lastPathComponent,+ path: path,+ size: size,+ category: .brewCache,+ isSelected: true,+ lastModified: nil+ ))+ }+ }+ }++ let totalSize = items.reduce(0) { $0 + $1.size }+ return CategoryResult(category: .brewCache, items: items, totalSize: totalSize)+ }++ // MARK: - Helpers++ private func scanDirectory(path: String, category: CleaningCategory, recursive: Bool, maxDepth: Int) -> [CleanableItem] {+ var items: [CleanableItem] = []++ guard fileManager.fileExists(atPath: path),+ fileManager.isReadableFile(atPath: path) else { return [] }++ do {+ let contents = try fileManager.contentsOfDirectory(atPath: path)+ for item in contents {+ let fullPath = (path as NSString).appendingPathComponent(item)++ var isDir: ObjCBool = false+ guard fileManager.fileExists(atPath: fullPath, isDirectory: &isDir) else { continue }++ if isDir.boolValue {+ let size = directorySize(path: fullPath)+ if size > 1024 { // Skip tiny entries+ items.append(CleanableItem(+ name: item,+ path: fullPath,+ size: size,+ category: category,+ isSelected: true,+ lastModified: fileModDate(path: fullPath)+ ))+ }+ } else {+ if let attrs = try? fileManager.attributesOfItem(atPath: fullPath),+ let size = attrs[.size] as? Int64, size > 1024 {+ items.append(CleanableItem(+ name: item,+ path: fullPath,+ size: size,+ category: category,+ isSelected: true,+ lastModified: attrs[.modificationDate] as? Date+ ))+ }+ }+ }+ } catch {+ // Permission denied or other error - skip silently+ }++ return items+ }++ private func directorySize(path: String) -> Int64 {+ var totalSize: Int64 = 0++ guard let enumerator = fileManager.enumerator(+ at: URL(fileURLWithPath: path),+ includingPropertiesForKeys: [.fileSizeKey, .isRegularFileKey],+ options: [.skipsHiddenFiles]+ ) else { return 0 }++ var count = 0+ for case let fileURL as URL in enumerator {+ count += 1+ if count > 10000 { break } // Safety limit for very large directories++ guard let values = try? fileURL.resourceValues(forKeys: [.fileSizeKey, .isRegularFileKey]),+ let isFile = values.isRegularFile, isFile,+ let size = values.fileSize else { continue }+ totalSize += Int64(size)+ }++ return totalSize+ }++ private func fileModDate(path: String) -> Date? {+ try? fileManager.attributesOfItem(atPath: path)[.modificationDate] as? Date+ }+}diff --git a/PureMac/Services/SchedulerService.swift b/PureMac/Services/SchedulerService.swiftnew file mode 100644index 0000000..59ffd61--- /dev/null+++ b/PureMac/Services/SchedulerService.swift@@ -0,0 +1,140 @@+import Foundation+import Combine++@MainActor+class SchedulerService: ObservableObject {+ @Published var config: ScheduleConfig {+ didSet { saveConfig() }+ }++ private var timer: Timer?+ private let configKey = "PureMac.ScheduleConfig"+ private var onTrigger: (() async -> Void)?++ init() {+ if let data = UserDefaults.standard.data(forKey: configKey),+ let saved = try? JSONDecoder().decode(ScheduleConfig.self, from: data) {+ self.config = saved+ } else {+ self.config = ScheduleConfig()+ }+ }++ func setTrigger(_ handler: @escaping () async -> Void) {+ self.onTrigger = handler+ }++ func start() {+ stop()+ guard config.isEnabled else { return }++ updateNextRunDate()++ timer = Timer.scheduledTimer(withTimeInterval: 60, repeats: true) { [weak self] _ in+ Task { @MainActor [weak self] in+ self?.checkAndRun()+ }+ }+ }++ func stop() {+ timer?.invalidate()+ timer = nil+ }++ func updateSchedule(interval: ScheduleInterval) {+ config.interval = interval+ updateNextRunDate()+ if config.isEnabled {+ start()+ }+ }++ func toggleEnabled(_ enabled: Bool) {+ config.isEnabled = enabled+ if enabled {+ start()+ } else {+ stop()+ }+ }++ // MARK: - Private++ private func checkAndRun() {+ guard config.isEnabled,+ let nextRun = config.nextRunDate,+ Date() >= nextRun else { return }++ config.lastRunDate = Date()+ updateNextRunDate()++ Task {+ await onTrigger?()+ }+ }++ private func updateNextRunDate() {+ let base = config.lastRunDate ?? Date()+ config.nextRunDate = base.addingTimeInterval(config.interval.seconds)+ }++ private func saveConfig() {+ if let data = try? JSONEncoder().encode(config) {+ UserDefaults.standard.set(data, forKey: configKey)+ }+ }++ // MARK: - LaunchAgent Management++ func installLaunchAgent() {+ let plistName = "com.puremac.scheduler"+ let plistPath = FileManager.default.homeDirectoryForCurrentUser+ .appendingPathComponent("Library/LaunchAgents/\(plistName).plist")++ guard let appPath = Bundle.main.executablePath else { return }++ let intervalSeconds = Int(config.interval.seconds)+ let plistContent = """+ <?xml version="1.0" encoding="UTF-8"?>+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+ <plist version="1.0">+ <dict>+ <key>Label</key>+ <string>\(plistName)</string>+ <key>ProgramArguments</key>+ <array>+ <string>\(appPath)</string>+ <string>--scheduled-clean</string>+ </array>+ <key>StartInterval</key>+ <integer>\(intervalSeconds)</integer>+ <key>RunAtLoad</key>+ <false/>+ </dict>+ </plist>+ """++ try? plistContent.write(to: plistPath, atomically: true, encoding: .utf8)++ let task = Process()+ task.executableURL = URL(fileURLWithPath: "/bin/launchctl")+ task.arguments = ["load", plistPath.path]+ try? task.run()+ task.waitUntilExit()+ }++ func uninstallLaunchAgent() {+ let plistName = "com.puremac.scheduler"+ let plistPath = FileManager.default.homeDirectoryForCurrentUser+ .appendingPathComponent("Library/LaunchAgents/\(plistName).plist")++ let task = Process()+ task.executableURL = URL(fileURLWithPath: "/bin/launchctl")+ task.arguments = ["unload", plistPath.path]+ try? task.run()+ task.waitUntilExit()++ try? FileManager.default.removeItem(at: plistPath)+ }+}diff --git a/PureMac/ViewModels/AppViewModel.swift b/PureMac/ViewModels/AppViewModel.swiftnew file mode 100644index 0000000..190557c--- /dev/null+++ b/PureMac/ViewModels/AppViewModel.swift@@ -0,0 +1,232 @@+import SwiftUI+import Combine++@MainActor+class AppViewModel: ObservableObject {+ // MARK: - State+ @Published var selectedCategory: CleaningCategory = .smartScan+ @Published var scanState: ScanState = .idle+ @Published var categoryResults: [CleaningCategory: CategoryResult] = [:]+ @Published var diskInfo = DiskInfo()+ @Published var totalJunkSize: Int64 = 0+ @Published var totalFreedSpace: Int64 = 0+ @Published var scanProgress: Double = 0+ @Published var cleanProgress: Double = 0+ @Published var currentScanCategory: String = ""+ @Published var showCleanConfirmation = false+ @Published var lastCleanedDate: Date?+ @Published var selectedItems: Set<UUID> = []++ var scheduler = SchedulerService()+ private let scanEngine = ScanEngine()+ private let cleaningEngine = CleaningEngine()++ // MARK: - Computed++ var totalItemCount: Int {+ categoryResults.values.reduce(0) { $0 + $1.itemCount }+ }++ var currentCategoryResult: CategoryResult? {+ categoryResults[selectedCategory]+ }++ var allResults: [CategoryResult] {+ CleaningCategory.scannable.compactMap { categoryResults[$0] }.filter { $0.totalSize > 0 }+ }++ // MARK: - Init++ init() {+ loadDiskInfo()+ scheduler.setTrigger { [weak self] in+ await self?.runScheduledScan()+ }+ scheduler.start()+ }++ // MARK: - Disk Info++ func loadDiskInfo() {+ Task {+ let info = await scanEngine.getDiskInfo()+ self.diskInfo = info+ }+ }++ // MARK: - Scanning++ func startSmartScan() {+ guard !scanState.isActive else { return }++ scanState = .scanning(progress: 0, currentCategory: "Preparing...")+ categoryResults = [:]+ totalJunkSize = 0+ scanProgress = 0++ Task {+ let categories = CleaningCategory.scannable+ let total = categories.count++ for (index, category) in categories.enumerated() {+ let progress = Double(index) / Double(total)+ scanProgress = progress+ currentScanCategory = category.rawValue+ scanState = .scanning(progress: progress, currentCategory: category.rawValue)++ let result = await scanEngine.scanCategory(category)+ categoryResults[category] = result+ totalJunkSize += result.totalSize+ }++ scanProgress = 1.0+ scanState = .completed+ loadDiskInfo()+ }+ }++ func scanSingleCategory(_ category: CleaningCategory) {+ guard !scanState.isActive else { return }++ scanState = .scanning(progress: 0, currentCategory: category.rawValue)+ scanProgress = 0++ Task {+ scanProgress = 0.5+ let result = await scanEngine.scanCategory(category)+ categoryResults[category] = result++ // Recalculate total+ totalJunkSize = categoryResults.values.reduce(0) { $0 + $1.totalSize }+ scanProgress = 1.0+ scanState = .completed+ }+ }++ // MARK: - Cleaning++ func cleanAll() {+ guard !scanState.isActive else { return }++ let itemsToClean = allResults.flatMap { $0.items.filter { $0.isSelected } }+ guard !itemsToClean.isEmpty else { return }++ scanState = .cleaning(progress: 0)+ cleanProgress = 0++ Task {+ let result = await cleaningEngine.cleanItems(itemsToClean) { [weak self] progress in+ Task { @MainActor [weak self] in+ self?.cleanProgress = progress+ self?.scanState = .cleaning(progress: progress)+ }+ }++ totalFreedSpace = result.freedSpace+ lastCleanedDate = Date()++ // Clear results+ categoryResults = [:]+ totalJunkSize = 0+ scanState = .cleaned+ loadDiskInfo()++ // Reset state after delay+ try? await Task.sleep(nanoseconds: 3_000_000_000)+ scanState = .idle+ totalFreedSpace = 0+ }+ }++ func cleanCategory(_ category: CleaningCategory) {+ guard let result = categoryResults[category], !scanState.isActive else { return }++ scanState = .cleaning(progress: 0)+ cleanProgress = 0++ Task {+ let cleanResult = await cleaningEngine.cleanCategory(result) { [weak self] progress in+ Task { @MainActor [weak self] in+ self?.cleanProgress = progress+ self?.scanState = .cleaning(progress: progress)+ }+ }++ totalFreedSpace = cleanResult.freedSpace+ lastCleanedDate = Date()++ categoryResults.removeValue(forKey: category)+ totalJunkSize = categoryResults.values.reduce(0) { $0 + $1.totalSize }+ scanState = .cleaned+ loadDiskInfo()++ try? await Task.sleep(nanoseconds: 3_000_000_000)+ scanState = .idle+ totalFreedSpace = 0+ }+ }++ // MARK: - Purgeable++ func purgePurgeable() {+ guard !scanState.isActive else { return }++ scanState = .cleaning(progress: 0)++ Task {+ scanState = .cleaning(progress: 0.5)+ let freed = await cleaningEngine.purgePurgeableSpace()+ totalFreedSpace = freed+ scanState = .cleaned+ loadDiskInfo()++ try? await Task.sleep(nanoseconds: 3_000_000_000)+ scanState = .idle+ totalFreedSpace = 0+ }+ }++ // MARK: - Scheduled Scan++ private func runScheduledScan() async {+ let categories = scheduler.config.categoriesToScan+ var totalFound: Int64 = 0++ for category in categories {+ let result = await scanEngine.scanCategory(category)+ categoryResults[category] = result+ totalFound += result.totalSize+ }++ totalJunkSize = totalFound++ if scheduler.config.autoClean && totalFound >= scheduler.config.minimumCleanSize {+ cleanAll()+ }++ if scheduler.config.autoPurge {+ _ = await cleaningEngine.purgePurgeableSpace()+ }++ if scheduler.config.notifyOnCompletion {+ sendNotification(freed: totalFound)+ }+ }++ private func sendNotification(freed: Int64) {+ let content = UNMutableNotificationContent()+ content.title = "PureMac"+ content.body = "Found \(ByteCountFormatter.string(fromByteCount: freed, countStyle: .file)) of junk files."+ content.sound = .default++ let request = UNNotificationRequest(+ identifier: UUID().uuidString,+ content: content,+ trigger: nil+ )++ UNUserNotificationCenter.current().add(request)+ }+}++import UserNotificationsdiff --git a/PureMac/Views/CategoryDetailView.swift b/PureMac/Views/CategoryDetailView.swiftnew file mode 100644index 0000000..f283e79--- /dev/null+++ b/PureMac/Views/CategoryDetailView.swift@@ -0,0 +1,267 @@+import SwiftUI++struct CategoryDetailView: View {+ @EnvironmentObject var vm: AppViewModel+ let category: CleaningCategory++ var result: CategoryResult? {+ vm.categoryResults[category]+ }++ var body: some View {+ VStack(spacing: 0) {+ // Category header+ categoryHeader+ .padding(.horizontal, 32)+ .padding(.top, 16)+ .padding(.bottom, 16)++ if let result = result {+ if result.items.isEmpty {+ emptyState+ } else {+ // File list+ fileList(result)+ }+ } else {+ // Not scanned yet+ notScannedState+ }++ Spacer()++ // Action bar+ categoryActionBar+ .padding(.horizontal, 32)+ .padding(.bottom, 32)+ }+ }++ // MARK: - Header++ private var categoryHeader: some View {+ HStack(spacing: 16) {+ ZStack {+ RoundedRectangle(cornerRadius: 12)+ .fill(category.color.opacity(0.15))+ .frame(width: 48, height: 48)++ Image(systemName: category.icon)+ .font(.system(size: 22))+ .foregroundColor(category.color)+ }++ VStack(alignment: .leading, spacing: 4) {+ Text(category.rawValue)+ .font(.pmHeadline)+ .foregroundColor(.pmTextPrimary)++ Text(category.description)+ .font(.pmCaption)+ .foregroundColor(.pmTextSecondary)+ }++ Spacer()++ if let result = result {+ VStack(alignment: .trailing, spacing: 4) {+ Text(result.formattedSize)+ .font(.pmMediumNumber)+ .foregroundColor(category.color)++ Text("\(result.itemCount) items")+ .font(.pmCaption)+ .foregroundColor(.pmTextMuted)+ }+ }+ }+ }++ // MARK: - File List++ private func fileList(_ result: CategoryResult) -> some View {+ ScrollView {+ LazyVStack(spacing: 4) {+ ForEach(result.items) { item in+ FileRow(item: item, color: category.color)+ }+ }+ .padding(.horizontal, 32)+ .padding(.vertical, 8)+ }+ }++ // MARK: - Empty / Not Scanned++ private var emptyState: some View {+ VStack(spacing: 16) {+ Spacer()+ Image(systemName: "checkmark.circle.fill")+ .font(.system(size: 48))+ .foregroundColor(.pmSuccess)++ Text("All Clean!")+ .font(.pmHeadline)+ .foregroundColor(.pmTextPrimary)++ Text("No junk files found in this category.")+ .font(.pmBody)+ .foregroundColor(.pmTextSecondary)+ Spacer()+ }+ }++ private var notScannedState: some View {+ VStack(spacing: 16) {+ Spacer()+ ZStack {+ Circle()+ .fill(category.color.opacity(0.1))+ .frame(width: 120, height: 120)++ Image(systemName: category.icon)+ .font(.system(size: 40))+ .foregroundColor(category.color.opacity(0.5))+ }++ Text("Not scanned yet")+ .font(.pmSubheadline)+ .foregroundColor(.pmTextSecondary)++ Text("Click Scan to analyze this category")+ .font(.pmCaption)+ .foregroundColor(.pmTextMuted)+ Spacer()+ }+ }++ // MARK: - Action Bar++ private var categoryActionBar: some View {+ HStack(spacing: 16) {+ if result == nil || vm.scanState == .idle || vm.scanState == .completed {+ GradientActionButton(+ title: "Scan",+ icon: "magnifyingglass",+ gradient: LinearGradient(+ colors: [category.color, category.color.opacity(0.7)],+ startPoint: .leading,+ endPoint: .trailing+ )+ ) {+ withAnimation(.pmSpring) {+ vm.scanSingleCategory(category)+ }+ }+ }++ if let result = result, result.totalSize > 0 && !vm.scanState.isActive {+ GradientActionButton(+ title: "Clean (\(result.formattedSize))",+ icon: "trash.fill",+ gradient: AppGradients.accent+ ) {+ withAnimation(.pmSpring) {+ vm.cleanCategory(category)+ }+ }+ }+ }+ }+}++// MARK: - File Row++struct FileRow: View {+ let item: CleanableItem+ let color: Color++ @State private var isHovering = false++ var body: some View {+ HStack(spacing: 12) {+ // File icon+ Image(systemName: fileIcon)+ .font(.system(size: 14))+ .foregroundColor(color.opacity(0.7))+ .frame(width: 24)++ // File info+ VStack(alignment: .leading, spacing: 2) {+ Text(item.name)+ .font(.pmBody)+ .foregroundColor(.pmTextPrimary)+ .lineLimit(1)+ .truncationMode(.middle)++ Text(item.path)+ .font(.system(size: 10))+ .foregroundColor(.pmTextMuted)+ .lineLimit(1)+ .truncationMode(.middle)+ }++ Spacer()++ // Date+ if let date = item.lastModified {+ Text(formatDate(date))+ .font(.system(size: 10))+ .foregroundColor(.pmTextMuted)+ }++ // Size+ Text(item.formattedSize)+ .font(.system(size: 12, weight: .semibold, design: .rounded))+ .foregroundColor(.pmTextPrimary)+ .frame(width: 70, alignment: .trailing)++ // Reveal button on hover+ if isHovering {+ Button(action: revealInFinder) {+ Image(systemName: "arrow.right.circle")+ .font(.system(size: 12))+ .foregroundColor(.pmTextSecondary)+ }+ .buttonStyle(.plain)+ }+ }+ .padding(.horizontal, 16)+ .padding(.vertical, 8)+ .background(+ RoundedRectangle(cornerRadius: 8)+ .fill(isHovering ? Color.pmCard : Color.clear)+ )+ .onHover { h in+ withAnimation(.pmSmooth) { isHovering = h }+ }+ }++ private var fileIcon: String {+ let ext = (item.name as NSString).pathExtension.lowercased()+ switch ext {+ case "log", "txt": return "doc.text.fill"+ case "zip", "gz", "tar": return "doc.zipper"+ case "dmg", "iso": return "opticaldisc.fill"+ case "app": return "app.fill"+ case "pkg": return "shippingbox.fill"+ default:+ var isDir: ObjCBool = false+ if FileManager.default.fileExists(atPath: item.path, isDirectory: &isDir), isDir.boolValue {+ return "folder.fill"+ }+ return "doc.fill"+ }+ }++ private func formatDate(_ date: Date) -> String {+ let formatter = DateFormatter()+ formatter.dateStyle = .short+ formatter.timeStyle = .none+ return formatter.string(from: date)+ }++ private func revealInFinder() {+ NSWorkspace.shared.selectFile(item.path, inFileViewerRootedAtPath: "")+ }+}diff --git a/PureMac/Views/ContentView.swift b/PureMac/Views/ContentView.swiftnew file mode 100644index 0000000..a728c90--- /dev/null+++ b/PureMac/Views/ContentView.swift@@ -0,0 +1,128 @@+import SwiftUI++struct ContentView: View {+ @EnvironmentObject var vm: AppViewModel++ var body: some View {+ HStack(spacing: 0) {+ SidebarView()+ .frame(width: 220)++ Divider()+ .background(Color.pmSeparator)++ // Main content+ ZStack {+ Color.pmBackground+ .ignoresSafeArea()++ VStack(spacing: 0) {+ // Top bar with disk info+ TopBarView()+ .padding(.horizontal, 24)+ .padding(.top, 16)+ .padding(.bottom, 8)++ // Content area+ Group {+ switch vm.selectedCategory {+ case .smartScan:+ SmartScanView()+ default:+ CategoryDetailView(category: vm.selectedCategory)+ }+ }+ .frame(maxWidth: .infinity, maxHeight: .infinity)+ }+ }+ }+ .background(Color.pmBackground)+ .onAppear {+ NSWindow.allowsAutomaticWindowTabbing = false+ }+ }+}++// MARK: - Top Bar++struct TopBarView: View {+ @EnvironmentObject var vm: AppViewModel++ var body: some View {+ HStack(spacing: 16) {+ // Disk usage indicator+ HStack(spacing: 12) {+ Image(systemName: "internaldrive.fill")+ .font(.system(size: 16))+ .foregroundColor(.pmAccentLight)++ VStack(alignment: .leading, spacing: 4) {+ Text("Macintosh HD")+ .font(.pmCaption)+ .foregroundColor(.pmTextPrimary)++ GeometryReader { geo in+ ZStack(alignment: .leading) {+ RoundedRectangle(cornerRadius: 3)+ .fill(Color.pmCard)+ .frame(height: 6)++ RoundedRectangle(cornerRadius: 3)+ .fill(+ vm.diskInfo.usedPercentage > 0.9 ? AppGradients.danger :+ vm.diskInfo.usedPercentage > 0.7 ? AppGradients.accent :+ AppGradients.success+ )+ .frame(width: geo.size.width * vm.diskInfo.usedPercentage, height: 6)+ }+ }+ .frame(height: 6)+ }+ .frame(width: 160)++ Text("\(vm.diskInfo.formattedFree) free")+ .font(.pmCaption)+ .foregroundColor(.pmTextSecondary)+ }+ .padding(.horizontal, 16)+ .padding(.vertical, 10)+ .background(Color.pmCard.opacity(0.6))+ .cornerRadius(10)++ Spacer()++ // Schedule indicator+ if vm.scheduler.config.isEnabled {+ HStack(spacing: 6) {+ Circle()+ .fill(Color.pmSuccess)+ .frame(width: 6, height: 6)+ Text("Auto-clean: \(vm.scheduler.config.interval.rawValue)")+ .font(.pmCaption)+ .foregroundColor(.pmTextSecondary)+ }+ .padding(.horizontal, 12)+ .padding(.vertical, 6)+ .background(Color.pmCard.opacity(0.6))+ .cornerRadius(8)+ }++ // Settings button+ Button(action: {+ if #available(macOS 14.0, *) {+ NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)+ } else {+ NSApp.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)+ }+ }) {+ Image(systemName: "gearshape.fill")+ .font(.system(size: 14))+ .foregroundColor(.pmTextSecondary)+ .frame(width: 32, height: 32)+ .background(Color.pmCard.opacity(0.6))+ .cornerRadius(8)+ }+ .buttonStyle(.plain)+ }+ }+}diff --git a/PureMac/Views/SettingsView.swift b/PureMac/Views/SettingsView.swiftnew file mode 100644index 0000000..f9318ce--- /dev/null+++ b/PureMac/Views/SettingsView.swift@@ -0,0 +1,234 @@+import SwiftUI++struct SettingsView: View {+ @EnvironmentObject var vm: AppViewModel++ var body: some View {+ TabView {+ ScheduleSettingsTab()+ .environmentObject(vm)+ .tabItem {+ Label("Schedule", systemImage: "clock.fill")+ }++ GeneralSettingsTab()+ .tabItem {+ Label("General", systemImage: "gearshape.fill")+ }++ AboutTab()+ .tabItem {+ Label("About", systemImage: "info.circle.fill")+ }+ }+ .frame(width: 520, height: 440)+ }+}++// MARK: - Schedule Settings++struct ScheduleSettingsTab: View {+ @EnvironmentObject var vm: AppViewModel++ var body: some View {+ VStack(alignment: .leading, spacing: 24) {+ // Enable toggle+ VStack(alignment: .leading, spacing: 8) {+ Toggle(isOn: Binding(+ get: { vm.scheduler.config.isEnabled },+ set: { vm.scheduler.toggleEnabled($0) }+ )) {+ VStack(alignment: .leading, spacing: 4) {+ Text("Automatic Cleaning")+ .font(.system(size: 14, weight: .semibold))+ Text("Automatically scan and clean your Mac on a schedule")+ .font(.system(size: 12))+ .foregroundColor(.secondary)+ }+ }+ .toggleStyle(.switch)+ }++ Divider()++ // Interval picker+ VStack(alignment: .leading, spacing: 8) {+ Text("Scan Interval")+ .font(.system(size: 13, weight: .semibold))++ Picker("", selection: Binding(+ get: { vm.scheduler.config.interval },+ set: { vm.scheduler.updateSchedule(interval: $0) }+ )) {+ ForEach(ScheduleInterval.allCases) { interval in+ Text(interval.rawValue).tag(interval)+ }+ }+ .pickerStyle(.menu)+ .frame(width: 200)+ .disabled(!vm.scheduler.config.isEnabled)+ }++ Divider()++ // Auto-clean options+ VStack(alignment: .leading, spacing: 12) {+ Text("Automation")+ .font(.system(size: 13, weight: .semibold))++ Toggle("Auto-clean after scan", isOn: $vm.scheduler.config.autoClean)+ .toggleStyle(.switch)+ .disabled(!vm.scheduler.config.isEnabled)++ if vm.scheduler.config.autoClean {+ HStack {+ Text("Minimum junk size to trigger clean:")+ .font(.system(size: 12))+ .foregroundColor(.secondary)++ Picker("", selection: Binding(+ get: { vm.scheduler.config.minimumCleanSize },+ set: { vm.scheduler.config.minimumCleanSize = $0 }+ )) {+ Text("50 MB").tag(Int64(50 * 1024 * 1024))+ Text("100 MB").tag(Int64(100 * 1024 * 1024))+ Text("250 MB").tag(Int64(250 * 1024 * 1024))+ Text("500 MB").tag(Int64(500 * 1024 * 1024))+ Text("1 GB").tag(Int64(1024 * 1024 * 1024))+ }+ .pickerStyle(.menu)+ .frame(width: 120)+ }+ .padding(.leading, 20)+ }++ Toggle("Auto-purge purgeable space", isOn: $vm.scheduler.config.autoPurge)+ .toggleStyle(.switch)+ .disabled(!vm.scheduler.config.isEnabled)++ Toggle("Show notification on completion", isOn: $vm.scheduler.config.notifyOnCompletion)+ .toggleStyle(.switch)+ .disabled(!vm.scheduler.config.isEnabled)+ }++ Divider()++ // Status+ VStack(alignment: .leading, spacing: 8) {+ Text("Status")+ .font(.system(size: 13, weight: .semibold))++ HStack(spacing: 16) {+ VStack(alignment: .leading, spacing: 4) {+ Text("Last run")+ .font(.system(size: 11))+ .foregroundColor(.secondary)+ Text(vm.scheduler.config.formattedLastRun)+ .font(.system(size: 12, weight: .medium))+ }++ VStack(alignment: .leading, spacing: 4) {+ Text("Next run")+ .font(.system(size: 11))+ .foregroundColor(.secondary)+ Text(vm.scheduler.config.formattedNextRun)+ .font(.system(size: 12, weight: .medium))+ }+ }+ }++ Spacer()+ }+ .padding(24)+ }+}++// MARK: - General Settings++struct GeneralSettingsTab: View {+ @AppStorage("PureMac.LaunchAtLogin") private var launchAtLogin = false+ @AppStorage("PureMac.ShowInDock") private var showInDock = true+ @AppStorage("PureMac.ShowMenuBarIcon") private var showMenuBarIcon = true++ var body: some View {+ VStack(alignment: .leading, spacing: 24) {+ VStack(alignment: .leading, spacing: 12) {+ Text("App Behavior")+ .font(.system(size: 13, weight: .semibold))++ Toggle("Launch at login", isOn: $launchAtLogin)+ .toggleStyle(.switch)++ Toggle("Show in Dock", isOn: $showInDock)+ .toggleStyle(.switch)++ Toggle("Show menu bar icon", isOn: $showMenuBarIcon)+ .toggleStyle(.switch)+ }++ Divider()++ VStack(alignment: .leading, spacing: 12) {+ Text("Safety")+ .font(.system(size: 13, weight: .semibold))++ Text("PureMac will never delete system-critical files. Only caches, logs, temporary files, and user-selected items are removed.")+ .font(.system(size: 12))+ .foregroundColor(.secondary)+ .fixedSize(horizontal: false, vertical: true)+ }++ Spacer()+ }+ .padding(24)+ }+}++// MARK: - About Tab++struct AboutTab: View {+ var body: some View {+ VStack(spacing: 20) {+ Spacer()++ ZStack {+ Circle()+ .fill(+ LinearGradient(+ colors: [Color(hex: "6366f1"), Color(hex: "a855f7")],+ startPoint: .topLeading,+ endPoint: .bottomTrailing+ )+ )+ .frame(width: 80, height: 80)++ Image(systemName: "sparkles")+ .font(.system(size: 32, weight: .bold))+ .foregroundColor(.white)+ }++ Text("PureMac")+ .font(.system(size: 24, weight: .bold, design: .rounded))++ Text("Version 1.0.0")+ .font(.system(size: 13))+ .foregroundColor(.secondary)++ Text("A free, open-source Mac cleaning utility.\nKeep your Mac fast, clean, and optimized.")+ .font(.system(size: 12))+ .foregroundColor(.secondary)+ .multilineTextAlignment(.center)+ .fixedSize(horizontal: false, vertical: true)++ Link("GitHub Repository", destination: URL(string: "https://github.com/momenbasel/PureMac")!)+ .font(.system(size: 12))++ Text("MIT License")+ .font(.system(size: 11))+ .foregroundColor(.secondary)++ Spacer()+ }+ .padding(24)+ }+}diff --git a/PureMac/Views/SidebarView.swift b/PureMac/Views/SidebarView.swiftnew file mode 100644index 0000000..8f6f69c--- /dev/null+++ b/PureMac/Views/SidebarView.swift@@ -0,0 +1,180 @@+import SwiftUI++struct SidebarView: View {+ @EnvironmentObject var vm: AppViewModel++ var body: some View {+ VStack(spacing: 0) {+ // App logo / title+ VStack(spacing: 8) {+ HStack(spacing: 10) {+ ZStack {+ Circle()+ .fill(AppGradients.primary)+ .frame(width: 36, height: 36)+ Image(systemName: "sparkles")+ .font(.system(size: 16, weight: .bold))+ .foregroundColor(.white)+ }++ Text("PureMac")+ .font(.system(size: 20, weight: .bold, design: .rounded))+ .foregroundColor(.pmTextPrimary)++ Spacer()+ }+ .padding(.horizontal, 20)+ }+ .padding(.top, 48) // Account for title bar+ .padding(.bottom, 24)++ // Category list+ ScrollView(.vertical, showsIndicators: false) {+ VStack(spacing: 2) {+ // Smart Scan - always first+ SidebarItem(+ category: .smartScan,+ isSelected: vm.selectedCategory == .smartScan,+ resultSize: vm.totalJunkSize+ )+ .onTapGesture { vm.selectedCategory = .smartScan }++ Divider()+ .background(Color.pmSeparator)+ .padding(.horizontal, 16)+ .padding(.vertical, 8)++ // Section header+ HStack {+ Text("CLEANING")+ .font(.system(size: 10, weight: .bold, design: .rounded))+ .foregroundColor(.pmTextMuted)+ .tracking(1.2)+ Spacer()+ }+ .padding(.horizontal, 20)+ .padding(.bottom, 4)++ ForEach(CleaningCategory.scannable) { category in+ SidebarItem(+ category: category,+ isSelected: vm.selectedCategory == category,+ resultSize: vm.categoryResults[category]?.totalSize+ )+ .onTapGesture { vm.selectedCategory = category }+ }+ }+ .padding(.bottom, 16)+ }++ Spacer()++ // Bottom info+ VStack(spacing: 8) {+ Divider()+ .background(Color.pmSeparator)++ if let lastCleaned = vm.lastCleanedDate {+ HStack {+ Image(systemName: "checkmark.circle.fill")+ .font(.system(size: 10))+ .foregroundColor(.pmSuccess)+ Text("Last cleaned: \(timeAgo(lastCleaned))")+ .font(.system(size: 10))+ .foregroundColor(.pmTextMuted)+ }+ .padding(.horizontal, 16)+ }++ Text("v1.0.0")+ .font(.system(size: 10))+ .foregroundColor(.pmTextMuted)+ .padding(.bottom, 12)+ }+ }+ .background(+ ZStack {+ AppGradients.sidebar+ .ignoresSafeArea()+ // Subtle right border glow+ HStack {+ Spacer()+ Rectangle()+ .fill(+ LinearGradient(+ colors: [.pmAccent.opacity(0.05), .clear],+ startPoint: .trailing,+ endPoint: .leading+ )+ )+ .frame(width: 1)+ }+ }+ )+ }++ func timeAgo(_ date: Date) -> String {+ let formatter = RelativeDateTimeFormatter()+ formatter.unitsStyle = .abbreviated+ return formatter.localizedString(for: date, relativeTo: Date())+ }+}++// MARK: - Sidebar Item++struct SidebarItem: View {+ let category: CleaningCategory+ let isSelected: Bool+ let resultSize: Int64?++ @State private var isHovering = false++ var body: some View {+ HStack(spacing: 12) {+ // Icon+ ZStack {+ RoundedRectangle(cornerRadius: 8)+ .fill(isSelected ? category.color.opacity(0.2) : Color.clear)+ .frame(width: 32, height: 32)++ Image(systemName: category.icon)+ .font(.system(size: 14))+ .foregroundColor(isSelected ? category.color : .pmTextSecondary)+ }++ // Label+ VStack(alignment: .leading, spacing: 2) {+ Text(category.rawValue)+ .font(.pmBody)+ .foregroundColor(isSelected ? .pmTextPrimary : .pmTextSecondary)+ .lineLimit(1)++ if let size = resultSize, size > 0 {+ Text(ByteCountFormatter.string(fromByteCount: size, countStyle: .file))+ .font(.system(size: 10, weight: .medium, design: .rounded))+ .foregroundColor(category.color)+ }+ }++ Spacer()++ // Size badge+ if let size = resultSize, size > 0, !isSelected {+ Circle()+ .fill(category.color.opacity(0.2))+ .frame(width: 8, height: 8)+ }+ }+ .padding(.horizontal, 16)+ .padding(.vertical, 8)+ .background(+ RoundedRectangle(cornerRadius: 10)+ .fill(isSelected ? Color.pmCard : (isHovering ? Color.pmCard.opacity(0.5) : .clear))+ )+ .padding(.horizontal, 8)+ .onHover { hovering in+ withAnimation(.pmSmooth) { isHovering = hovering }+ }+ .contentShape(Rectangle())+ }+}diff --git a/PureMac/Views/SmartScanView.swift b/PureMac/Views/SmartScanView.swiftnew file mode 100644index 0000000..ee9cbd8--- /dev/null+++ b/PureMac/Views/SmartScanView.swift@@ -0,0 +1,522 @@+import SwiftUI++struct SmartScanView: View {+ @EnvironmentObject var vm: AppViewModel++ var body: some View {+ VStack(spacing: 0) {+ Spacer()++ switch vm.scanState {+ case .idle:+ idleView+ case .scanning:+ scanningView+ case .completed:+ completedView+ case .cleaning:+ cleaningView+ case .cleaned:+ cleanedView+ }++ Spacer()++ // Bottom action bar+ actionBar+ .padding(.bottom, 32)+ }+ .padding(.horizontal, 40)+ }++ // MARK: - Idle View++ private var idleView: some View {+ VStack(spacing: 24) {+ ZStack {+ // Outer glow ring+ Circle()+ .stroke(Color.pmAccent.opacity(0.1), lineWidth: 2)+ .frame(width: 220, height: 220)++ Circle()+ .stroke(Color.pmAccent.opacity(0.05), lineWidth: 1)+ .frame(width: 250, height: 250)++ // Main circle+ Circle()+ .fill(+ RadialGradient(+ colors: [Color.pmAccent.opacity(0.15), Color.pmBackground],+ center: .center,+ startRadius: 20,+ endRadius: 110+ )+ )+ .frame(width: 200, height: 200)++ VStack(spacing: 8) {+ Image(systemName: "sparkles")+ .font(.system(size: 40))+ .foregroundColor(.pmAccentLight)++ Text("Smart Scan")+ .font(.pmHeadline)+ .foregroundColor(.pmTextPrimary)++ Text("Click Scan to start")+ .font(.pmCaption)+ .foregroundColor(.pmTextMuted)+ }+ }+ .pmGlow(color: .pmAccent, radius: 40)++ // Disk overview+ diskOverview+ }+ }++ // MARK: - Scanning View++ private var scanningView: some View {+ VStack(spacing: 24) {+ ZStack {+ // Background ring+ Circle()+ .stroke(Color.pmCard, lineWidth: 8)+ .frame(width: 200, height: 200)++ // Progress ring+ Circle()+ .trim(from: 0, to: vm.scanProgress)+ .stroke(+ AppGradients.scanRing,+ style: StrokeStyle(lineWidth: 8, lineCap: .round)+ )+ .frame(width: 200, height: 200)+ .rotationEffect(.degrees(-90))+ .animation(.easeInOut(duration: 0.3), value: vm.scanProgress)++ // Spinning outer ring+ Circle()+ .trim(from: 0, to: 0.3)+ .stroke(+ Color.pmAccent.opacity(0.3),+ style: StrokeStyle(lineWidth: 2, lineCap: .round)+ )+ .frame(width: 230, height: 230)+ .rotationEffect(.degrees(rotationAngle))++ VStack(spacing: 4) {+ Text("\(Int(vm.scanProgress * 100))%")+ .font(.pmLargeNumber)+ .foregroundColor(.pmTextPrimary)+ .contentTransition(.numericText())++ Text(vm.currentScanCategory)+ .font(.pmCaption)+ .foregroundColor(.pmTextSecondary)+ .lineLimit(1)+ }+ }++ // Live results+ if !vm.allResults.isEmpty {+ liveResults+ }+ }+ .onAppear { startRotation() }+ }++ // MARK: - Completed View++ private var completedView: some View {+ VStack(spacing: 24) {+ ZStack {+ Circle()+ .stroke(Color.pmCard, lineWidth: 8)+ .frame(width: 200, height: 200)++ Circle()+ .trim(from: 0, to: 1)+ .stroke(+ AppGradients.primary,+ style: StrokeStyle(lineWidth: 8, lineCap: .round)+ )+ .frame(width: 200, height: 200)+ .rotationEffect(.degrees(-90))++ VStack(spacing: 4) {+ Text(ByteCountFormatter.string(fromByteCount: vm.totalJunkSize, countStyle: .file))+ .font(.pmLargeNumber)+ .foregroundColor(.pmTextPrimary)++ Text("junk found")+ .font(.pmSubheadline)+ .foregroundColor(.pmTextSecondary)+ }+ }+ .pmGlow(color: vm.totalJunkSize > 0 ? .pmWarning : .pmSuccess, radius: 30)++ // Results breakdown+ if !vm.allResults.isEmpty {+ resultsBreakdown+ } else {+ VStack(spacing: 8) {+ Image(systemName: "checkmark.circle.fill")+ .font(.system(size: 32))+ .foregroundColor(.pmSuccess)+ Text("Your Mac is clean!")+ .font(.pmSubheadline)+ .foregroundColor(.pmTextSecondary)+ }+ }+ }+ }++ // MARK: - Cleaning View++ private var cleaningView: some View {+ VStack(spacing: 24) {+ ZStack {+ Circle()+ .stroke(Color.pmCard, lineWidth: 8)+ .frame(width: 200, height: 200)++ Circle()+ .trim(from: 0, to: vm.cleanProgress)+ .stroke(+ AppGradients.danger,+ style: StrokeStyle(lineWidth: 8, lineCap: .round)+ )+ .frame(width: 200, height: 200)+ .rotationEffect(.degrees(-90))+ .animation(.easeInOut(duration: 0.3), value: vm.cleanProgress)++ VStack(spacing: 4) {+ Image(systemName: "trash.fill")+ .font(.system(size: 28))+ .foregroundColor(.pmDanger)++ Text("Cleaning...")+ .font(.pmSubheadline)+ .foregroundColor(.pmTextSecondary)++ Text("\(Int(vm.cleanProgress * 100))%")+ .font(.pmMediumNumber)+ .foregroundColor(.pmTextPrimary)+ .contentTransition(.numericText())+ }+ }+ }+ }++ // MARK: - Cleaned View++ private var cleanedView: some View {+ VStack(spacing: 24) {+ ZStack {+ Circle()+ .fill(Color.pmSuccess.opacity(0.1))+ .frame(width: 200, height: 200)++ VStack(spacing: 8) {+ Image(systemName: "checkmark.circle.fill")+ .font(.system(size: 48))+ .foregroundColor(.pmSuccess)++ Text(ByteCountFormatter.string(fromByteCount: vm.totalFreedSpace, countStyle: .file))+ .font(.pmLargeNumber)+ .foregroundColor(.pmSuccess)++ Text("freed up")+ .font(.pmSubheadline)+ .foregroundColor(.pmTextSecondary)+ }+ }+ .pmGlow(color: .pmSuccess, radius: 40)+ }+ .transition(.scale.combined(with: .opacity))+ }++ // MARK: - Sub Views++ private var diskOverview: some View {+ HStack(spacing: 24) {+ DiskStatCard(+ title: "Total",+ value: vm.diskInfo.formattedTotal,+ icon: "internaldrive.fill",+ color: .pmAccent+ )+ DiskStatCard(+ title: "Used",+ value: vm.diskInfo.formattedUsed,+ icon: "chart.pie.fill",+ color: .pmWarning+ )+ DiskStatCard(+ title: "Free",+ value: vm.diskInfo.formattedFree,+ icon: "checkmark.circle.fill",+ color: .pmSuccess+ )+ if vm.diskInfo.purgeableSpace > 0 {+ DiskStatCard(+ title: "Purgeable",+ value: vm.diskInfo.formattedPurgeable,+ icon: "arrow.3.trianglepath",+ color: .pmInfo+ )+ }+ }+ }++ private var liveResults: some View {+ VStack(spacing: 8) {+ ForEach(vm.allResults.prefix(6)) { result in+ HStack(spacing: 12) {+ Image(systemName: result.category.icon)+ .font(.system(size: 12))+ .foregroundColor(result.category.color)+ .frame(width: 20)++ Text(result.category.rawValue)+ .font(.pmCaption)+ .foregroundColor(.pmTextSecondary)++ Spacer()++ Text(result.formattedSize)+ .font(.pmCaption)+ .foregroundColor(.pmTextPrimary)+ }+ .padding(.horizontal, 16)+ .padding(.vertical, 6)+ }+ }+ .padding(.vertical, 12)+ .background(Color.pmCard.opacity(0.5))+ .cornerRadius(12)+ .frame(maxWidth: 400)+ }++ private var resultsBreakdown: some View {+ VStack(spacing: 8) {+ ForEach(vm.allResults) { result in+ HStack(spacing: 12) {+ ZStack {+ RoundedRectangle(cornerRadius: 6)+ .fill(result.category.color.opacity(0.15))+ .frame(width: 28, height: 28)++ Image(systemName: result.category.icon)+ .font(.system(size: 12))+ .foregroundColor(result.category.color)+ }++ VStack(alignment: .leading, spacing: 2) {+ Text(result.category.rawValue)+ .font(.pmBody)+ .foregroundColor(.pmTextPrimary)++ Text("\(result.itemCount) items")+ .font(.system(size: 10))+ .foregroundColor(.pmTextMuted)+ }++ Spacer()++ Text(result.formattedSize)+ .font(.system(size: 14, weight: .semibold, design: .rounded))+ .foregroundColor(result.category.color)+ }+ .padding(.horizontal, 16)+ .padding(.vertical, 8)+ .background(Color.pmCard.opacity(0.4))+ .cornerRadius(10)+ }+ }+ .frame(maxWidth: 450)+ }++ // MARK: - Action Bar++ private var actionBar: some View {+ HStack(spacing: 16) {+ switch vm.scanState {+ case .idle:+ GradientActionButton(+ title: "Scan",+ icon: "magnifyingglass",+ gradient: AppGradients.primary+ ) {+ withAnimation(.pmSpring) {+ vm.startSmartScan()+ }+ }++ case .scanning:+ Button(action: {}) {+ HStack(spacing: 8) {+ ProgressView()+ .progressViewStyle(.circular)+ .scaleEffect(0.7)+ .tint(.white)+ Text("Scanning...")+ .font(.pmSubheadline)+ .foregroundColor(.pmTextSecondary)+ }+ .frame(width: 200, height: 44)+ .background(Color.pmCard)+ .cornerRadius(12)+ }+ .buttonStyle(.plain)+ .disabled(true)++ case .completed:+ if vm.totalJunkSize > 0 {+ GradientActionButton(+ title: "Clean (\(ByteCountFormatter.string(fromByteCount: vm.totalJunkSize, countStyle: .file)))",+ icon: "trash.fill",+ gradient: AppGradients.accent+ ) {+ withAnimation(.pmSpring) {+ vm.cleanAll()+ }+ }++ Button(action: {+ withAnimation(.pmSpring) {+ vm.startSmartScan()+ }+ }) {+ Text("Re-scan")+ .font(.pmBody)+ .foregroundColor(.pmTextSecondary)+ .frame(height: 44)+ .padding(.horizontal, 24)+ .background(Color.pmCard)+ .cornerRadius(12)+ }+ .buttonStyle(.plain)+ } else {+ GradientActionButton(+ title: "Scan Again",+ icon: "arrow.clockwise",+ gradient: AppGradients.success+ ) {+ withAnimation(.pmSpring) {+ vm.startSmartScan()+ }+ }+ }++ case .cleaning:+ Button(action: {}) {+ HStack(spacing: 8) {+ ProgressView()+ .progressViewStyle(.circular)+ .scaleEffect(0.7)+ .tint(.white)+ Text("Cleaning...")+ .font(.pmSubheadline)+ .foregroundColor(.pmTextSecondary)+ }+ .frame(width: 200, height: 44)+ .background(Color.pmCard)+ .cornerRadius(12)+ }+ .buttonStyle(.plain)+ .disabled(true)++ case .cleaned:+ GradientActionButton(+ title: "Done",+ icon: "checkmark",+ gradient: AppGradients.success+ ) {+ withAnimation(.pmSpring) {+ vm.scanState = .idle+ }+ }+ }+ }+ }++ // MARK: - Animation State++ @State private var rotationAngle: Double = 0+ @State private var rotationTimer: Timer?++ private func startRotation() {+ rotationTimer?.invalidate()+ rotationTimer = Timer.scheduledTimer(withTimeInterval: 0.02, repeats: true) { _ in+ DispatchQueue.main.async {+ rotationAngle += 1.5+ if rotationAngle >= 360 { rotationAngle = 0 }+ }+ }+ }+}++// MARK: - Disk Stat Card++struct DiskStatCard: View {+ let title: String+ let value: String+ let icon: String+ let color: Color++ var body: some View {+ VStack(spacing: 8) {+ Image(systemName: icon)+ .font(.system(size: 16))+ .foregroundColor(color)++ Text(value)+ .font(.system(size: 14, weight: .bold, design: .rounded))+ .foregroundColor(.pmTextPrimary)++ Text(title)+ .font(.system(size: 10, weight: .medium))+ .foregroundColor(.pmTextMuted)+ }+ .frame(width: 100, height: 80)+ .background(Color.pmCard.opacity(0.5))+ .cornerRadius(12)+ }+}++// MARK: - Gradient Action Button++struct GradientActionButton: View {+ let title: String+ let icon: String+ let gradient: LinearGradient+ let action: () -> Void++ @State private var isHovering = false++ var body: some View {+ Button(action: action) {+ HStack(spacing: 8) {+ Image(systemName: icon)+ .font(.system(size: 14, weight: .semibold))+ Text(title)+ .font(.system(size: 15, weight: .semibold, design: .rounded))+ }+ .foregroundColor(.white)+ .frame(height: 44)+ .padding(.horizontal, 32)+ .background(gradient)+ .cornerRadius(12)+ .scaleEffect(isHovering ? 1.03 : 1.0)+ .pmShadow(radius: isHovering ? 15 : 8, y: isHovering ? 6 : 4)+ }+ .buttonStyle(.plain)+ .onHover { h in+ withAnimation(.pmSmooth) { isHovering = h }+ }+ }+}diff --git a/README.md b/README.mdnew file mode 100644index 0000000..59d6dc1--- /dev/null+++ b/README.md@@ -0,0 +1,94 @@+# PureMac++A free, open-source macOS cleaning utility. Keep your Mac fast, clean, and optimized.++++++## Features++- **Smart Scan** - Scan all categories at once with a single click+- **System Junk** - Clean system caches, logs, and temporary files+- **User Cache** - Remove application caches and browser data+- **Mail Attachments** - Clear downloaded mail attachments+- **Trash Bins** - Empty your Trash+- **Large & Old Files** - Find files over 100 MB or older than 1 year+- **Purgeable Space** - Purge APFS purgeable disk space+- **Xcode Junk** - Clean derived data, archives, and simulator caches+- **Homebrew Cache** - Clear Homebrew download cache+- **Scheduled Cleaning** - Automatic scans on configurable intervals (hours/days/weeks)+- **Auto-Purge** - Automatically purge purgeable files on schedule++## Screenshots++The app features a dark, modern UI inspired by professional Mac utilities:++- Dark gradient theme with vibrant accent colors+- Animated circular scan progress indicator+- Sidebar navigation with real-time size indicators+- Disk usage overview bar++## Requirements++- macOS 13.0 (Ventura) or later+- Xcode 15+ (for building from source)+- [XcodeGen](https://github.com/yonaskolb/XcodeGen) (for project generation)++## Building++```bash+# Install XcodeGen if you don't have it+brew install xcodegen++# Clone the repo+git clone https://github.com/momenbasel/PureMac.git+cd PureMac++# Generate Xcode project+xcodegen generate++# Build+xcodebuild -project PureMac.xcodeproj -scheme PureMac -configuration Release build++# Or open in Xcode+open PureMac.xcodeproj+```++The built app will be at `build/Build/Products/Release/PureMac.app`.++## Scheduling++PureMac supports automatic cleaning on configurable intervals:++1. Open **Settings** (gear icon or Cmd+,)+2. Go to the **Schedule** tab+3. Enable **Automatic Cleaning**+4. Choose your preferred interval (every hour to monthly)+5. Optionally enable **Auto-clean after scan** and **Auto-purge purgeable space**++The scheduler runs while the app is open. A LaunchAgent can be installed for background scheduling.++## What Gets Cleaned++| Category | Paths |+|---|---|+| System Junk | `/Library/Caches`, `/Library/Logs`, `/tmp`, `~/Library/Logs` |+| User Cache | `~/Library/Caches`, npm/pip/yarn/pnpm caches |+| Mail Attachments | `~/Library/Mail Downloads` |+| Trash | `~/.Trash` |+| Large Files | `~/Downloads`, `~/Documents`, `~/Desktop` (>100MB or >1yr old) |+| Purgeable | APFS purgeable space via `diskutil` |+| Xcode | `DerivedData`, `Archives`, `CoreSimulator/Caches` |+| Homebrew | `~/Library/Caches/Homebrew` |++## Safety++- Never deletes system-critical files+- Only removes caches, logs, temporary files, and user-selected items+- Large & Old Files are **not auto-selected** - you choose what to remove+- All operations are non-destructive to the operating system++## License++MIT License. See [LICENSE](LICENSE) for details.diff --git a/project.yml b/project.ymlnew file mode 100644index 0000000..a1628b4--- /dev/null+++ b/project.yml@@ -0,0 +1,35 @@+name: PureMac+options:+ bundleIdPrefix: com.puremac+ deploymentTarget:+ macOS: "13.0"+ xcodeVersion: "16.4"+ createIntermediateGroups: true+ defaultConfig: Release++settings:+ base:+ SWIFT_VERSION: "5.9"+ MACOSX_DEPLOYMENT_TARGET: "13.0"+ CODE_SIGN_IDENTITY: "-"+ CODE_SIGNING_REQUIRED: "NO"+ CODE_SIGN_ENTITLEMENTS: "PureMac/PureMac.entitlements"+ INFOPLIST_FILE: "PureMac/Info.plist"+ PRODUCT_BUNDLE_IDENTIFIER: "com.puremac.app"+ MARKETING_VERSION: "1.0.0"+ CURRENT_PROJECT_VERSION: "1"+ GENERATE_INFOPLIST_FILE: "NO"+ ASSETCATALOG_COMPILER_APPICON_NAME: "AppIcon"+ COMBINE_HIDPI_IMAGES: "YES"++targets:+ PureMac:+ type: application+ platform: macOS+ sources:+ - PureMac+ settings:+ base:+ PRODUCT_NAME: PureMac+ SWIFT_EMIT_LOC_STRINGS: "YES"+ LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/../Frameworks"