From f325271aa502daaeb0d95c5d455c884931f9452a Mon Sep 17 00:00:00 2001 From: "Vinicius.Correia1" Date: Wed, 29 May 2024 23:49:10 -0300 Subject: [PATCH 1/7] feature: adding blank home page to the project --- MacCleaner.xcodeproj/project.pbxproj | 50 +++++++++++++++++- MacCleaner/ContentView.swift | 24 --------- MacCleaner/Model/StorageInfo.swift | 30 +++++++++++ .../Views/ContentView/ContentView.swift | 33 ++++++++++++ MacCleaner/Views/Dashboard.swift | 52 +++++++++++++++++++ MacCleaner/Views/LargeFilesFinder.swift | 18 +++++++ MacCleaner/Views/SystemCleanup.swift | 18 +++++++ MacCleaner/Views/SystemMonitor.swift | 18 +++++++ MacCleaner/Views/Uninstaller.swift | 19 +++++++ 9 files changed, 237 insertions(+), 25 deletions(-) delete mode 100644 MacCleaner/ContentView.swift create mode 100644 MacCleaner/Model/StorageInfo.swift create mode 100644 MacCleaner/Views/ContentView/ContentView.swift create mode 100644 MacCleaner/Views/Dashboard.swift create mode 100644 MacCleaner/Views/LargeFilesFinder.swift create mode 100644 MacCleaner/Views/SystemCleanup.swift create mode 100644 MacCleaner/Views/SystemMonitor.swift create mode 100644 MacCleaner/Views/Uninstaller.swift diff --git a/MacCleaner.xcodeproj/project.pbxproj b/MacCleaner.xcodeproj/project.pbxproj index f154bf4..b6d3f51 100644 --- a/MacCleaner.xcodeproj/project.pbxproj +++ b/MacCleaner.xcodeproj/project.pbxproj @@ -14,6 +14,12 @@ 79D4658F2C081E070061176E /* MacCleanerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D4658E2C081E070061176E /* MacCleanerTests.swift */; }; 79D465992C081E070061176E /* MacCleanerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465982C081E070061176E /* MacCleanerUITests.swift */; }; 79D4659B2C081E070061176E /* MacCleanerUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D4659A2C081E070061176E /* MacCleanerUITestsLaunchTests.swift */; }; + 79D465A92C081E4E0061176E /* SystemCleanup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465A82C081E4E0061176E /* SystemCleanup.swift */; }; + 79D465AC2C081E760061176E /* LargeFilesFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465AB2C081E760061176E /* LargeFilesFinder.swift */; }; + 79D465AE2C081E900061176E /* Uninstaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465AD2C081E900061176E /* Uninstaller.swift */; }; + 79D465B02C081E9F0061176E /* SystemMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465AF2C081E9F0061176E /* SystemMonitor.swift */; }; + 79D465B32C081F320061176E /* StorageInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465B22C081F320061176E /* StorageInfo.swift */; }; + 79D465B52C081F560061176E /* Dashboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465B42C081F560061176E /* Dashboard.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -45,6 +51,12 @@ 79D465942C081E070061176E /* MacCleanerUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MacCleanerUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 79D465982C081E070061176E /* MacCleanerUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacCleanerUITests.swift; sourceTree = ""; }; 79D4659A2C081E070061176E /* MacCleanerUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacCleanerUITestsLaunchTests.swift; sourceTree = ""; }; + 79D465A82C081E4E0061176E /* SystemCleanup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemCleanup.swift; sourceTree = ""; }; + 79D465AB2C081E760061176E /* LargeFilesFinder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LargeFilesFinder.swift; sourceTree = ""; }; + 79D465AD2C081E900061176E /* Uninstaller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Uninstaller.swift; sourceTree = ""; }; + 79D465AF2C081E9F0061176E /* SystemMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemMonitor.swift; sourceTree = ""; }; + 79D465B22C081F320061176E /* StorageInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageInfo.swift; sourceTree = ""; }; + 79D465B42C081F560061176E /* Dashboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dashboard.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -95,8 +107,9 @@ 79D4657B2C081E050061176E /* MacCleaner */ = { isa = PBXGroup; children = ( + 79D465B12C081F230061176E /* Model */, + 79D465A72C081E3C0061176E /* Views */, 79D4657C2C081E050061176E /* MacCleanerApp.swift */, - 79D4657E2C081E050061176E /* ContentView.swift */, 79D465802C081E060061176E /* Assets.xcassets */, 79D465852C081E060061176E /* MacCleaner.entitlements */, 79D465822C081E060061176E /* Preview Content */, @@ -129,6 +142,35 @@ path = MacCleanerUITests; sourceTree = ""; }; + 79D465A72C081E3C0061176E /* Views */ = { + isa = PBXGroup; + children = ( + 79D465AA2C081E670061176E /* ContentView */, + 79D465A82C081E4E0061176E /* SystemCleanup.swift */, + 79D465AB2C081E760061176E /* LargeFilesFinder.swift */, + 79D465AD2C081E900061176E /* Uninstaller.swift */, + 79D465AF2C081E9F0061176E /* SystemMonitor.swift */, + 79D465B42C081F560061176E /* Dashboard.swift */, + ); + path = Views; + sourceTree = ""; + }; + 79D465AA2C081E670061176E /* ContentView */ = { + isa = PBXGroup; + children = ( + 79D4657E2C081E050061176E /* ContentView.swift */, + ); + path = ContentView; + sourceTree = ""; + }; + 79D465B12C081F230061176E /* Model */ = { + isa = PBXGroup; + children = ( + 79D465B22C081F320061176E /* StorageInfo.swift */, + ); + path = Model; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -260,7 +302,13 @@ buildActionMask = 2147483647; files = ( 79D4657F2C081E050061176E /* ContentView.swift in Sources */, + 79D465B32C081F320061176E /* StorageInfo.swift in Sources */, + 79D465B52C081F560061176E /* Dashboard.swift in Sources */, 79D4657D2C081E050061176E /* MacCleanerApp.swift in Sources */, + 79D465A92C081E4E0061176E /* SystemCleanup.swift in Sources */, + 79D465B02C081E9F0061176E /* SystemMonitor.swift in Sources */, + 79D465AE2C081E900061176E /* Uninstaller.swift in Sources */, + 79D465AC2C081E760061176E /* LargeFilesFinder.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacCleaner/ContentView.swift b/MacCleaner/ContentView.swift deleted file mode 100644 index a859af5..0000000 --- a/MacCleaner/ContentView.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// ContentView.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 29/05/24. -// - -import SwiftUI - -struct ContentView: View { - var body: some View { - VStack { - Image(systemName: "globe") - .imageScale(.large) - .foregroundStyle(.tint) - Text("Hello, world!") - } - .padding() - } -} - -#Preview { - ContentView() -} diff --git a/MacCleaner/Model/StorageInfo.swift b/MacCleaner/Model/StorageInfo.swift new file mode 100644 index 0000000..0dcfab3 --- /dev/null +++ b/MacCleaner/Model/StorageInfo.swift @@ -0,0 +1,30 @@ +// +// StorageInfo.swift +// MacCleaner +// +// Created by Vinicius Mangueira on 29/05/24. +// + +import Foundation + +struct StorageInfo { + var totalSpace: Int64 + var freeSpace: Int64 + var usedSpace: Int64 +} + +func getStorageInfo() -> StorageInfo? { + if let homeDirectory = try? FileManager.default.url(for: .userDirectory, in: .localDomainMask, appropriateFor: nil, create: false) { + do { + let attributes = try FileManager.default.attributesOfFileSystem(forPath: homeDirectory.path) + if let totalSpace = attributes[.systemSize] as? Int64, + let freeSpace = attributes[.systemFreeSize] as? Int64 { + let usedSpace = totalSpace - freeSpace + return StorageInfo(totalSpace: totalSpace, freeSpace: freeSpace, usedSpace: usedSpace) + } + } catch { + print("Error retrieving storage information: \(error.localizedDescription)") + } + } + return nil +} diff --git a/MacCleaner/Views/ContentView/ContentView.swift b/MacCleaner/Views/ContentView/ContentView.swift new file mode 100644 index 0000000..a2a77d2 --- /dev/null +++ b/MacCleaner/Views/ContentView/ContentView.swift @@ -0,0 +1,33 @@ +import SwiftUI + +struct ContentView: View { + var body: some View { + NavigationView { + Sidebar() + Dashboard() + } + } +} + +struct Sidebar: View { + var body: some View { + List { + NavigationLink(destination: Dashboard()) { + Label("Dashboard", systemImage: "gauge") + } + NavigationLink(destination: SystemCleanup()) { + Label("System Cleanup", systemImage: "trash") + } + NavigationLink(destination: LargeFilesFinder()) { + Label("Large & Old Files", systemImage: "doc.text.magnifyingglass") + } + NavigationLink(destination: Uninstaller()) { + Label("Uninstaller", systemImage: "trash.slash") + } + NavigationLink(destination: SystemMonitor()) { + Label("System Monitor", systemImage: "waveform.path.ecg") + } + } + .listStyle(SidebarListStyle()) + } +} diff --git a/MacCleaner/Views/Dashboard.swift b/MacCleaner/Views/Dashboard.swift new file mode 100644 index 0000000..b93f096 --- /dev/null +++ b/MacCleaner/Views/Dashboard.swift @@ -0,0 +1,52 @@ +// +// Dashboard.swift +// MacCleaner +// +// Created by Vinicius Mangueira on 29/05/24. +// + +import SwiftUI + +struct Dashboard: View { + @State private var storageInfo: StorageInfo? = getStorageInfo() + + var body: some View { + VStack { + Text("Dashboard") + .font(.largeTitle) + .padding() + + if let storageInfo = storageInfo { + VStack(alignment: .leading) { + Text("Storage Information") + .font(.headline) + .padding(.bottom) + + Text("Total Space: \(formatBytes(storageInfo.totalSpace))") + Text("Free Space: \(formatBytes(storageInfo.freeSpace))") + Text("Used Space: \(formatBytes(storageInfo.usedSpace))") + } + .padding() + .background(Color.secondary.opacity(0.1)) + .cornerRadius(10) + .padding() + } else { + Text("Unable to retrieve storage information") + .foregroundColor(.red) + .padding() + } + + Spacer() + } + .onAppear { + self.storageInfo = getStorageInfo() + } + } + + private func formatBytes(_ bytes: Int64) -> String { + let formatter = ByteCountFormatter() + formatter.allowedUnits = [.useGB, .useMB] + formatter.countStyle = .file + return formatter.string(fromByteCount: bytes) + } +} diff --git a/MacCleaner/Views/LargeFilesFinder.swift b/MacCleaner/Views/LargeFilesFinder.swift new file mode 100644 index 0000000..a9f2b49 --- /dev/null +++ b/MacCleaner/Views/LargeFilesFinder.swift @@ -0,0 +1,18 @@ +// +// LargeFilesFinder.swift +// MacCleaner +// +// Created by Vinicius Mangueira on 29/05/24. +// + +import SwiftUI + +struct LargeFilesFinder: View { + var body: some View { + VStack { + Text("Large & Old Files") + .font(.largeTitle) + .padding() + } + } +} diff --git a/MacCleaner/Views/SystemCleanup.swift b/MacCleaner/Views/SystemCleanup.swift new file mode 100644 index 0000000..678c8d4 --- /dev/null +++ b/MacCleaner/Views/SystemCleanup.swift @@ -0,0 +1,18 @@ +// +// SystemCleanup.swift +// MacCleaner +// +// Created by Vinicius Mangueira on 29/05/24. +// + +import SwiftUI + +struct SystemCleanup: View { + var body: some View { + VStack { + Text("System Cleanup") + .font(.largeTitle) + .padding() + } + } +} diff --git a/MacCleaner/Views/SystemMonitor.swift b/MacCleaner/Views/SystemMonitor.swift new file mode 100644 index 0000000..a7b8b5d --- /dev/null +++ b/MacCleaner/Views/SystemMonitor.swift @@ -0,0 +1,18 @@ +// +// SystemMonitor.swift +// MacCleaner +// +// Created by Vinicius Mangueira on 29/05/24. +// + +import SwiftUI + +struct SystemMonitor: View { + var body: some View { + VStack { + Text("System Monitor") + .font(.largeTitle) + .padding() + } + } +} diff --git a/MacCleaner/Views/Uninstaller.swift b/MacCleaner/Views/Uninstaller.swift new file mode 100644 index 0000000..8b626bb --- /dev/null +++ b/MacCleaner/Views/Uninstaller.swift @@ -0,0 +1,19 @@ +// +// Uninstaller.swift +// MacCleaner +// +// Created by Vinicius Mangueira on 29/05/24. +// + +import SwiftUI + +struct Uninstaller: View { + var body: some View { + VStack { + Text("Uninstaller") + .font(.largeTitle) + .padding() + } + } +} + From 9efdaee9c0db349472fee44c8ed25fe9b938cb27 Mon Sep 17 00:00:00 2001 From: "Vinicius.Correia1" Date: Thu, 30 May 2024 00:46:12 -0300 Subject: [PATCH 2/7] feature: adding function to find files --- MacCleaner.xcodeproj/project.pbxproj | 20 ++++++++--- MacCleaner/MacCleanerApp.swift | 7 +--- MacCleaner/Model/FileInfo.swift | 42 ++++++++++++++++++++++ MacCleaner/Model/SystemCleanUp.swift | 8 +++++ MacCleaner/Model/SystemMonitorHelper.swift | 8 +++++ MacCleaner/Views/DeveloperTools.swift | 31 ++++++++++++++++ MacCleaner/Views/SystemMonitor.swift | 18 ---------- 7 files changed, 106 insertions(+), 28 deletions(-) create mode 100644 MacCleaner/Model/FileInfo.swift create mode 100644 MacCleaner/Model/SystemCleanUp.swift create mode 100644 MacCleaner/Model/SystemMonitorHelper.swift create mode 100644 MacCleaner/Views/DeveloperTools.swift delete mode 100644 MacCleaner/Views/SystemMonitor.swift diff --git a/MacCleaner.xcodeproj/project.pbxproj b/MacCleaner.xcodeproj/project.pbxproj index b6d3f51..adb43f9 100644 --- a/MacCleaner.xcodeproj/project.pbxproj +++ b/MacCleaner.xcodeproj/project.pbxproj @@ -17,9 +17,12 @@ 79D465A92C081E4E0061176E /* SystemCleanup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465A82C081E4E0061176E /* SystemCleanup.swift */; }; 79D465AC2C081E760061176E /* LargeFilesFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465AB2C081E760061176E /* LargeFilesFinder.swift */; }; 79D465AE2C081E900061176E /* Uninstaller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465AD2C081E900061176E /* Uninstaller.swift */; }; - 79D465B02C081E9F0061176E /* SystemMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465AF2C081E9F0061176E /* SystemMonitor.swift */; }; + 79D465B02C081E9F0061176E /* DeveloperTools.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465AF2C081E9F0061176E /* DeveloperTools.swift */; }; 79D465B32C081F320061176E /* StorageInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465B22C081F320061176E /* StorageInfo.swift */; }; 79D465B52C081F560061176E /* Dashboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465B42C081F560061176E /* Dashboard.swift */; }; + 79D465B72C0821510061176E /* SystemCleanUp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465B62C0821510061176E /* SystemCleanUp.swift */; }; + 79D465B92C0822F40061176E /* FileInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465B82C0822F40061176E /* FileInfo.swift */; }; + 79D465BB2C0826820061176E /* SystemMonitorHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79D465BA2C0826820061176E /* SystemMonitorHelper.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -54,9 +57,12 @@ 79D465A82C081E4E0061176E /* SystemCleanup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemCleanup.swift; sourceTree = ""; }; 79D465AB2C081E760061176E /* LargeFilesFinder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LargeFilesFinder.swift; sourceTree = ""; }; 79D465AD2C081E900061176E /* Uninstaller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Uninstaller.swift; sourceTree = ""; }; - 79D465AF2C081E9F0061176E /* SystemMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemMonitor.swift; sourceTree = ""; }; + 79D465AF2C081E9F0061176E /* DeveloperTools.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeveloperTools.swift; sourceTree = ""; }; 79D465B22C081F320061176E /* StorageInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageInfo.swift; sourceTree = ""; }; 79D465B42C081F560061176E /* Dashboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dashboard.swift; sourceTree = ""; }; + 79D465B62C0821510061176E /* SystemCleanUp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemCleanUp.swift; sourceTree = ""; }; + 79D465B82C0822F40061176E /* FileInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileInfo.swift; sourceTree = ""; }; + 79D465BA2C0826820061176E /* SystemMonitorHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemMonitorHelper.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -149,7 +155,7 @@ 79D465A82C081E4E0061176E /* SystemCleanup.swift */, 79D465AB2C081E760061176E /* LargeFilesFinder.swift */, 79D465AD2C081E900061176E /* Uninstaller.swift */, - 79D465AF2C081E9F0061176E /* SystemMonitor.swift */, + 79D465AF2C081E9F0061176E /* DeveloperTools.swift */, 79D465B42C081F560061176E /* Dashboard.swift */, ); path = Views; @@ -167,6 +173,9 @@ isa = PBXGroup; children = ( 79D465B22C081F320061176E /* StorageInfo.swift */, + 79D465B62C0821510061176E /* SystemCleanUp.swift */, + 79D465B82C0822F40061176E /* FileInfo.swift */, + 79D465BA2C0826820061176E /* SystemMonitorHelper.swift */, ); path = Model; sourceTree = ""; @@ -301,14 +310,17 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 79D465B72C0821510061176E /* SystemCleanUp.swift in Sources */, 79D4657F2C081E050061176E /* ContentView.swift in Sources */, 79D465B32C081F320061176E /* StorageInfo.swift in Sources */, 79D465B52C081F560061176E /* Dashboard.swift in Sources */, 79D4657D2C081E050061176E /* MacCleanerApp.swift in Sources */, 79D465A92C081E4E0061176E /* SystemCleanup.swift in Sources */, - 79D465B02C081E9F0061176E /* SystemMonitor.swift in Sources */, + 79D465B02C081E9F0061176E /* DeveloperTools.swift in Sources */, 79D465AE2C081E900061176E /* Uninstaller.swift in Sources */, 79D465AC2C081E760061176E /* LargeFilesFinder.swift in Sources */, + 79D465B92C0822F40061176E /* FileInfo.swift in Sources */, + 79D465BB2C0826820061176E /* SystemMonitorHelper.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MacCleaner/MacCleanerApp.swift b/MacCleaner/MacCleanerApp.swift index 2c4615a..806cdd9 100644 --- a/MacCleaner/MacCleanerApp.swift +++ b/MacCleaner/MacCleanerApp.swift @@ -1,9 +1,4 @@ -// -// MacCleanerApp.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. import SwiftUI diff --git a/MacCleaner/Model/FileInfo.swift b/MacCleaner/Model/FileInfo.swift new file mode 100644 index 0000000..f303e32 --- /dev/null +++ b/MacCleaner/Model/FileInfo.swift @@ -0,0 +1,42 @@ +// Copyright © 2024 MacCleaner, LLC. All rights reserved. + +import Foundation + +struct FileDetail: Identifiable { + let id = UUID() + let name: String + let size: Int64 + let modificationDate: Date +} + +func findLargeAndOldFiles(in directory: String, largerThan size: Int64, olderThan days: Int) -> [FileDetail] { + var results = [FileDetail]() + let fileManager = FileManager.default + let calendar = Calendar.current + let dateThreshold = calendar.date(byAdding: .day, value: -days, to: Date())! + + do { + let urls = try fileManager.contentsOfDirectory( + at: URL(fileURLWithPath: directory), + includingPropertiesForKeys: [.fileSizeKey, .contentModificationDateKey], + options: .skipsHiddenFiles + ) + + for url in urls { + let resourceValues = try url.resourceValues(forKeys: [.fileSizeKey, .contentModificationDateKey]) + if let fileSize = resourceValues.fileSize, let modificationDate = resourceValues.contentModificationDate { + if fileSize > size, modificationDate < dateThreshold { + results.append(FileDetail( + name: url.lastPathComponent, + size: Int64(fileSize), + modificationDate: modificationDate + )) + } + } + } + } catch { + print("Error while enumerating files \(directory): \(error.localizedDescription)") + } + + return results +} diff --git a/MacCleaner/Model/SystemCleanUp.swift b/MacCleaner/Model/SystemCleanUp.swift new file mode 100644 index 0000000..abfd4fc --- /dev/null +++ b/MacCleaner/Model/SystemCleanUp.swift @@ -0,0 +1,8 @@ +// +// SystemCleanUp.swift +// MacCleaner +// +// Created by Vinicius Mangueira on 29/05/24. +// + +import Foundation diff --git a/MacCleaner/Model/SystemMonitorHelper.swift b/MacCleaner/Model/SystemMonitorHelper.swift new file mode 100644 index 0000000..20c4dd4 --- /dev/null +++ b/MacCleaner/Model/SystemMonitorHelper.swift @@ -0,0 +1,8 @@ +// +// SystemMonitorHelper.swift +// MacCleaner +// +// Created by Vinicius Mangueira on 30/05/24. +// + +import Foundation diff --git a/MacCleaner/Views/DeveloperTools.swift b/MacCleaner/Views/DeveloperTools.swift new file mode 100644 index 0000000..1dbdea5 --- /dev/null +++ b/MacCleaner/Views/DeveloperTools.swift @@ -0,0 +1,31 @@ +// Copyright © 2024 MacCleaner, LLC. All rights reserved. + +import SwiftUI + +struct DeveloperTools: View { + var body: some View { + VStack { + Text("Developer Tools") + .font(.largeTitle) + .padding() + + Button(action: { + removeDerivedDataAndCache() + }) { + Text("Remove DerivedData and Xcode Cache") + .font(.title) + .padding() + .background(Color.red) + .foregroundColor(.white) + .cornerRadius(10) + } + + Spacer() + } + .padding() + } + + private func removeDerivedDataAndCache() { + print("DerivedData and Xcode cache removed successfully.") + } +} diff --git a/MacCleaner/Views/SystemMonitor.swift b/MacCleaner/Views/SystemMonitor.swift deleted file mode 100644 index a7b8b5d..0000000 --- a/MacCleaner/Views/SystemMonitor.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// SystemMonitor.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 29/05/24. -// - -import SwiftUI - -struct SystemMonitor: View { - var body: some View { - VStack { - Text("System Monitor") - .font(.largeTitle) - .padding() - } - } -} From 8e4b4d3b2f06903d9f5cda3f5660c8374ed4b24a Mon Sep 17 00:00:00 2001 From: "Vinicius.Correia1" Date: Thu, 30 May 2024 00:46:44 -0300 Subject: [PATCH 3/7] feature: adding function replace storage info --- MacCleaner/Model/StorageInfo.swift | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/MacCleaner/Model/StorageInfo.swift b/MacCleaner/Model/StorageInfo.swift index 0dcfab3..88f4c56 100644 --- a/MacCleaner/Model/StorageInfo.swift +++ b/MacCleaner/Model/StorageInfo.swift @@ -1,9 +1,4 @@ -// -// StorageInfo.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. import Foundation @@ -14,11 +9,17 @@ struct StorageInfo { } func getStorageInfo() -> StorageInfo? { - if let homeDirectory = try? FileManager.default.url(for: .userDirectory, in: .localDomainMask, appropriateFor: nil, create: false) { + if let homeDirectory = try? FileManager.default.url( + for: .userDirectory, + in: .localDomainMask, + appropriateFor: nil, + create: false + ) { do { let attributes = try FileManager.default.attributesOfFileSystem(forPath: homeDirectory.path) if let totalSpace = attributes[.systemSize] as? Int64, - let freeSpace = attributes[.systemFreeSize] as? Int64 { + let freeSpace = attributes[.systemFreeSize] as? Int64 + { let usedSpace = totalSpace - freeSpace return StorageInfo(totalSpace: totalSpace, freeSpace: freeSpace, usedSpace: usedSpace) } From 8e63a6f698763acaa59858316a34e4f409386071 Mon Sep 17 00:00:00 2001 From: "Vinicius.Correia1" Date: Thu, 30 May 2024 00:47:15 -0300 Subject: [PATCH 4/7] feature: adding function to a system clean up --- MacCleaner/Model/SystemCleanUp.swift | 28 ++++++-- MacCleaner/Model/SystemMonitorHelper.swift | 79 ++++++++++++++++++++-- 2 files changed, 95 insertions(+), 12 deletions(-) diff --git a/MacCleaner/Model/SystemCleanUp.swift b/MacCleaner/Model/SystemCleanUp.swift index abfd4fc..56c9a57 100644 --- a/MacCleaner/Model/SystemCleanUp.swift +++ b/MacCleaner/Model/SystemCleanUp.swift @@ -1,8 +1,24 @@ -// -// SystemCleanUp.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. import Foundation + +func performSystemCleanup() -> Bool { + let tempDirectories = [ + NSTemporaryDirectory(), + "/var/folders", + ] + + do { + for dir in tempDirectories { + let files = try FileManager.default.contentsOfDirectory(atPath: dir) + for file in files { + let filePath = (dir as NSString).appendingPathComponent(file) + try FileManager.default.removeItem(atPath: filePath) + } + } + return true + } catch { + print("Error during cleanup: \(error.localizedDescription)") + return false + } +} diff --git a/MacCleaner/Model/SystemMonitorHelper.swift b/MacCleaner/Model/SystemMonitorHelper.swift index 20c4dd4..d732cc5 100644 --- a/MacCleaner/Model/SystemMonitorHelper.swift +++ b/MacCleaner/Model/SystemMonitorHelper.swift @@ -1,8 +1,75 @@ -// -// SystemMonitorHelper.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 30/05/24. -// +// Copyright © 2023 Wendy's International, LLC. All rights reserved. import Foundation + +class SystemMonitorHelper { + static func getCPUUsage() -> Double { + var cpuInfo: processor_info_array_t! + var numCPUs: mach_msg_type_number_t = 0 + var prevIdleTicks: UInt64 = 0 + var prevTotalTicks: UInt64 = 0 + + var numCPUsCopy = numCPUs + + let err = host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &numCPUs, &cpuInfo, &numCPUsCopy) + if err == KERN_SUCCESS { + let cpuLoadInfo = cpuInfo! + .withMemoryRebound(to: Int32.self, capacity: Int(numCPUsCopy)) { ptr in + ptr + } + var totalTicks: UInt64 = 0 + var idleTicks: UInt64 = 0 + for cpu in 0 ..< Int(numCPUsCopy) { + totalTicks += UInt64(cpuLoadInfo[cpu]) + } + idleTicks = UInt64(cpuLoadInfo[Int(CPU_STATE_IDLE)]) + let totalTicksDiff = Double(totalTicks - prevTotalTicks) + let idleTicksDiff = Double(idleTicks - prevIdleTicks) + let usage = (totalTicksDiff - idleTicksDiff) / totalTicksDiff * 100.0 + prevIdleTicks = idleTicks + prevTotalTicks = totalTicks + return usage + } else { + print("Error getting CPU usage: \(String(describing: mach_error_string(err)))") + return 0.0 + } + } + + static func getMemoryUsage() -> Double { + var taskInfo = mach_task_basic_info() + var count = mach_msg_type_number_t(MemoryLayout.size / MemoryLayout.size) + let kerr: kern_return_t = withUnsafeMutablePointer(to: &taskInfo) { + $0.withMemoryRebound(to: integer_t.self, capacity: 1) { + task_info( + mach_task_self_, + task_flavor_t(MACH_TASK_BASIC_INFO), + $0, + &count + ) + } + } + if kerr == KERN_SUCCESS { + let usedMemory = taskInfo.resident_size + let totalMemory = ProcessInfo.processInfo.physicalMemory + return Double(usedMemory) / Double(totalMemory) * 100.0 + } else { + print("Error getting memory usage: \(String(describing: mach_error_string(kerr)))") + return 0.0 + } + } + + static func getDiskUsage() -> Double { + do { + let systemAttributes = try FileManager.default.attributesOfFileSystem(forPath: "/") + if let totalSize = systemAttributes[.systemSize] as? Int64, + let freeSize = systemAttributes[.systemFreeSize] as? Int64 + { + let usedSize = totalSize - freeSize + return Double(usedSize) / Double(totalSize) * 100.0 + } + } catch { + print("Error getting disk usage: \(error.localizedDescription)") + } + return 0.0 + } +} From 2bb851c09835b9df3fe646f0be7dbe541cc7163d Mon Sep 17 00:00:00 2001 From: "Vinicius.Correia1" Date: Thu, 30 May 2024 00:48:05 -0300 Subject: [PATCH 5/7] feature: adding view to represent home page --- .../xcdebugger/Breakpoints_v2.xcbkptlist | 6 ++ .../Views/ContentView/ContentView.swift | 20 ++++- MacCleaner/Views/Dashboard.swift | 68 ++++++++++++--- MacCleaner/Views/DeveloperTools.swift | 2 +- MacCleaner/Views/LargeFilesFinder.swift | 72 ++++++++++++++-- MacCleaner/Views/SystemCleanup.swift | 74 +++++++++++++++-- MacCleaner/Views/Uninstaller.swift | 83 +++++++++++++++++-- MacCleanerTests/MacCleanerTests.swift | 16 ++-- MacCleanerUITests/MacCleanerUITests.swift | 11 +-- .../MacCleanerUITestsLaunchTests.swift | 8 +- 10 files changed, 303 insertions(+), 57 deletions(-) create mode 100644 MacCleaner.xcodeproj/xcuserdata/viniciusmangueira.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist diff --git a/MacCleaner.xcodeproj/xcuserdata/viniciusmangueira.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/MacCleaner.xcodeproj/xcuserdata/viniciusmangueira.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..d06eac6 --- /dev/null +++ b/MacCleaner.xcodeproj/xcuserdata/viniciusmangueira.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/MacCleaner/Views/ContentView/ContentView.swift b/MacCleaner/Views/ContentView/ContentView.swift index a2a77d2..e537cc4 100644 --- a/MacCleaner/Views/ContentView/ContentView.swift +++ b/MacCleaner/Views/ContentView/ContentView.swift @@ -1,3 +1,5 @@ +// Copyright © 2024 MacCleaner, LLC. All rights reserved. + import SwiftUI struct ContentView: View { @@ -24,10 +26,24 @@ struct Sidebar: View { NavigationLink(destination: Uninstaller()) { Label("Uninstaller", systemImage: "trash.slash") } - NavigationLink(destination: SystemMonitor()) { - Label("System Monitor", systemImage: "waveform.path.ecg") + NavigationLink(destination: DeveloperTools()) { + Label("Developer", systemImage: "hammer") } } .listStyle(SidebarListStyle()) } } + +#Preview { + ContentView() +} + +struct CustomButtonStyle: ButtonStyle { + func makeBody(configuration: Configuration) -> some View { + configuration.label + .padding(10) + .background(configuration.isPressed ? Color.blue.opacity(0.5) : Color.blue) + .foregroundColor(.white) + .cornerRadius(8) + } +} diff --git a/MacCleaner/Views/Dashboard.swift b/MacCleaner/Views/Dashboard.swift index b93f096..11ac3cf 100644 --- a/MacCleaner/Views/Dashboard.swift +++ b/MacCleaner/Views/Dashboard.swift @@ -1,27 +1,25 @@ -// -// Dashboard.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. import SwiftUI struct Dashboard: View { @State private var storageInfo: StorageInfo? = getStorageInfo() + @State private var cpuUsage: Double = 0.0 + @State private var memoryUsage: Double = 0.0 + @State private var diskUsage: Double = 0.0 var body: some View { VStack { Text("Dashboard") .font(.largeTitle) .padding() - + if let storageInfo = storageInfo { VStack(alignment: .leading) { Text("Storage Information") .font(.headline) .padding(.bottom) - + Text("Total Space: \(formatBytes(storageInfo.totalSpace))") Text("Free Space: \(formatBytes(storageInfo.freeSpace))") Text("Used Space: \(formatBytes(storageInfo.usedSpace))") @@ -37,12 +35,33 @@ struct Dashboard: View { } Spacer() + + Text("System Monitor") + .font(.title) + .padding() + + VStack { + ProgressBar(value: cpuUsage, label: "CPU Usage", color: .blue) + ProgressBar(value: memoryUsage, label: "Memory Usage", color: .green) + ProgressBar(value: diskUsage, label: "Disk Usage", color: .orange) + } + .padding() } .onAppear { - self.storageInfo = getStorageInfo() + updateSystemInfo() + Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in + updateSystemInfo() + } } + .padding() } - + + private func updateSystemInfo() { + cpuUsage = SystemMonitorHelper.getCPUUsage() + memoryUsage = SystemMonitorHelper.getMemoryUsage() + diskUsage = SystemMonitorHelper.getDiskUsage() + } + private func formatBytes(_ bytes: Int64) -> String { let formatter = ByteCountFormatter() formatter.allowedUnits = [.useGB, .useMB] @@ -50,3 +69,32 @@ struct Dashboard: View { return formatter.string(fromByteCount: bytes) } } + +struct ProgressBar: View { + var value: Double + var label: String + var color: Color + + var body: some View { + VStack(alignment: .leading) { + Text(label) + .font(.headline) + GeometryReader { geometry in + ZStack(alignment: .leading) { + Rectangle() + .frame(width: geometry.size.width, height: 10) + .opacity(0.3) + .foregroundColor(Color.gray) + + Rectangle() + .frame(width: min(CGFloat(self.value) * geometry.size.width / 100, geometry.size.width), height: 10) + .foregroundColor(self.color) + .animation(.bouncy) + } + } + .frame(height: 10) + .cornerRadius(5.0) + } + .padding(.bottom, 10) + } +} diff --git a/MacCleaner/Views/DeveloperTools.swift b/MacCleaner/Views/DeveloperTools.swift index 1dbdea5..22aabbb 100644 --- a/MacCleaner/Views/DeveloperTools.swift +++ b/MacCleaner/Views/DeveloperTools.swift @@ -18,7 +18,7 @@ struct DeveloperTools: View { .background(Color.red) .foregroundColor(.white) .cornerRadius(10) - } + }.buttonStyle(CustomButtonStyle()) Spacer() } diff --git a/MacCleaner/Views/LargeFilesFinder.swift b/MacCleaner/Views/LargeFilesFinder.swift index a9f2b49..cf8b6cb 100644 --- a/MacCleaner/Views/LargeFilesFinder.swift +++ b/MacCleaner/Views/LargeFilesFinder.swift @@ -1,18 +1,78 @@ -// -// LargeFilesFinder.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. import SwiftUI struct LargeFilesFinder: View { + @State private var largeFiles: [FileDetail] = [] + @State private var scanCompleted = false + var body: some View { VStack { Text("Large & Old Files") .font(.largeTitle) .padding() + + Spacer() + + if scanCompleted { + List(largeFiles) { file in + HStack { + VStack(alignment: .leading) { + Text(file.name) + .font(.headline) + Text("Size: \(formatBytes(file.size))") + Text("Modified: \(formatDate(file.modificationDate))") + } + } + } + } else { + Text("Scanning for large and old files...") + .padding() + + Button(action: { + scanForLargeFiles() + }) { + Text("Start Scan") + .font(.title) + .padding() + .background(Color.blue) + .foregroundColor(.white) + .cornerRadius(10) + }.buttonStyle(CustomButtonStyle()) + } + + Spacer() } + .padding() + } + + private func scanForLargeFiles() { + DispatchQueue.global(qos: .background).async { + let directory = NSHomeDirectory() + let files = findLargeAndOldFiles( + in: directory, + largerThan: 50 * 1024 * 1024, + olderThan: 30 + ) + + DispatchQueue.main.async { + largeFiles = files + scanCompleted = true + } + } + } + + private func formatBytes(_ bytes: Int64) -> String { + let formatter = ByteCountFormatter() + formatter.allowedUnits = [.useGB, .useMB, .useKB] + formatter.countStyle = .file + return formatter.string(fromByteCount: bytes) + } + + private func formatDate(_ date: Date) -> String { + let formatter = DateFormatter() + formatter.dateStyle = .medium + formatter.timeStyle = .none + return formatter.string(from: date) } } diff --git a/MacCleaner/Views/SystemCleanup.swift b/MacCleaner/Views/SystemCleanup.swift index 678c8d4..36dcc98 100644 --- a/MacCleaner/Views/SystemCleanup.swift +++ b/MacCleaner/Views/SystemCleanup.swift @@ -1,18 +1,80 @@ -// -// SystemCleanup.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. import SwiftUI struct SystemCleanup: View { + @State private var showSheet = false + @State private var cleanupResult = "" + @State private var showingResult = false + var body: some View { VStack { Text("System Cleanup") .font(.largeTitle) .padding() + + Spacer() + + Button(action: { + showSheet = true + }) { + Text("Clean My Mac") + .font(.title) + .padding() + .background(Color.blue) + .foregroundColor(.white) + .cornerRadius(10) + } + .buttonStyle(CustomButtonStyle()) + .sheet(isPresented: $showSheet) { + VStack { + Text("Confirm Cleanup") + .font(.headline) + .padding() + + Text("Are you sure you want to clean your Mac? This will delete temporary files.") + .padding() + + HStack { + Button(action: { + if performSystemCleanup() { + cleanupResult = "Cleanup Successful!" + } else { + cleanupResult = "Cleanup Failed!" + } + showingResult = true + showSheet = false + }) { + Text("Clean") + .padding() + .background(Color.red) + .foregroundColor(.white) + .cornerRadius(10) + } + + Button(action: { + showSheet = false + }) { + Text("Cancel") + .padding() + .background(Color.gray) + .foregroundColor(.white) + .cornerRadius(10) + } + } + .padding() + } + .frame(width: 300, height: 200) + } + .alert(isPresented: $showingResult) { + Alert( + title: Text(cleanupResult), + dismissButton: .default(Text("OK")) + ) + } + + Spacer() } + .padding() } } diff --git a/MacCleaner/Views/Uninstaller.swift b/MacCleaner/Views/Uninstaller.swift index 8b626bb..658c524 100644 --- a/MacCleaner/Views/Uninstaller.swift +++ b/MacCleaner/Views/Uninstaller.swift @@ -1,19 +1,90 @@ -// -// Uninstaller.swift -// MacCleaner -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. import SwiftUI struct Uninstaller: View { + @State private var applications: [Application] = [] + @State private var selectedApplication: Application? + @State private var uninstallConfirmation = false + @State private var uninstallResult = "" + var body: some View { VStack { Text("Uninstaller") .font(.largeTitle) .padding() + + List(applications, id: \.self) { app in + Button(action: { + selectedApplication = app + uninstallConfirmation.toggle() + }) { + Text(app.name) + } + } + .frame(width: 300, height: 300) + + Spacer() + } + .padding() + .alert(isPresented: $uninstallConfirmation) { + Alert( + title: Text("Confirm Uninstall"), + message: Text("Are you sure you want to uninstall \(selectedApplication?.name ?? "")?"), + primaryButton: .destructive(Text("Uninstall")) { + uninstallApplication() + }, + secondaryButton: .cancel() + ) + } + .onAppear { + fetchInstalledApplications() + } + } + + private func fetchInstalledApplications() { + let applicationsURL = URL(fileURLWithPath: "/Applications") + do { + let applicationURLs = try FileManager.default.contentsOfDirectory( + at: applicationsURL, + includingPropertiesForKeys: nil, + options: .skipsHiddenFiles + ) + for url in applicationURLs { + if url.pathExtension == "app" { + let appName = url.lastPathComponent.replacingOccurrences(of: ".app", with: "") + if let bundle = Bundle(url: url) { + if let bundleID = bundle.bundleIdentifier { + applications.append(Application(name: appName, bundleID: bundleID)) + } + } + } + } + } catch { + print("Error fetching installed applications: \(error.localizedDescription)") + } + } + + private func uninstallApplication() { + guard let app = selectedApplication else { return } + do { + try FileManager.default.removeItem(at: URL(fileURLWithPath: "/Applications/\(app.name).app")) + uninstallResult = "\(app.name) has been uninstalled successfully." + // Remove the uninstalled application from the list + applications.removeAll(where: { $0 == app }) + } catch { + uninstallResult = "Failed to uninstall \(app.name)." } } } +struct Application: Hashable { + let name: String + let bundleID: String +} + +struct Uninstaller_Previews: PreviewProvider { + static var previews: some View { + Uninstaller() + } +} diff --git a/MacCleanerTests/MacCleanerTests.swift b/MacCleanerTests/MacCleanerTests.swift index 5d882a1..e6d4412 100644 --- a/MacCleanerTests/MacCleanerTests.swift +++ b/MacCleanerTests/MacCleanerTests.swift @@ -1,15 +1,9 @@ -// -// MacCleanerTests.swift -// MacCleanerTests -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. -import XCTest @testable import MacCleaner +import XCTest final class MacCleanerTests: XCTestCase { - override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. } @@ -23,14 +17,14 @@ final class MacCleanerTests: XCTestCase { // Use XCTAssert and related functions to verify your tests produce the correct results. // Any test you write for XCTest can be annotated as throws and async. // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. - // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. + // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions + // afterwards. } func testPerformanceExample() throws { // This is an example of a performance test case. - self.measure { + measure { // Put the code you want to measure the time of here. } } - } diff --git a/MacCleanerUITests/MacCleanerUITests.swift b/MacCleanerUITests/MacCleanerUITests.swift index a6679c3..f3f71c0 100644 --- a/MacCleanerUITests/MacCleanerUITests.swift +++ b/MacCleanerUITests/MacCleanerUITests.swift @@ -1,21 +1,16 @@ -// -// MacCleanerUITests.swift -// MacCleanerUITests -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. import XCTest final class MacCleanerUITests: XCTestCase { - override func setUpWithError() throws { // Put setup code here. This method is called before the invocation of each test method in the class. // In UI tests it is usually best to stop immediately when a failure occurs. continueAfterFailure = false - // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. + // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests + // before they run. The setUp method is a good place to do this. } override func tearDownWithError() throws { diff --git a/MacCleanerUITests/MacCleanerUITestsLaunchTests.swift b/MacCleanerUITests/MacCleanerUITestsLaunchTests.swift index ebdb0ab..5028abb 100644 --- a/MacCleanerUITests/MacCleanerUITestsLaunchTests.swift +++ b/MacCleanerUITests/MacCleanerUITestsLaunchTests.swift @@ -1,14 +1,8 @@ -// -// MacCleanerUITestsLaunchTests.swift -// MacCleanerUITests -// -// Created by Vinicius Mangueira on 29/05/24. -// +// Copyright © 2024 MacCleaner, LLC. All rights reserved. import XCTest final class MacCleanerUITestsLaunchTests: XCTestCase { - override class var runsForEachTargetApplicationUIConfiguration: Bool { true } From eb4584dd69245635f1e64b51f2cccfcd12cc0ff4 Mon Sep 17 00:00:00 2001 From: "Vinicius.Correia1" Date: Thu, 30 May 2024 00:49:36 -0300 Subject: [PATCH 6/7] Adding .gitignore file --- .gitignore | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..395f5d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# Xcode +.DS_Store +*/.DS_Store +*.xcuserstate +*.xcworkspace +xcuserdata/ + +# Build products +/build/ +DerivedData/ +*.build/ + +# Dependency directories +Pods/ +Carthage/Build/ + +# Swift Package Manager +.build/ + +# IDE files +*.swiftpm +.idea/ +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspective +*.perspectivev3 + +# macOS specific files +.DS_Store +profile + +# Miscellaneous +*.log +*.xccheckout + From 76d9d88c2dad1e64bd784f29aea05faf5df2afcd Mon Sep 17 00:00:00 2001 From: Vinicius Mangueira <32227073+ViniciusDeep@users.noreply.github.com> Date: Thu, 30 May 2024 00:57:33 -0300 Subject: [PATCH 7/7] Adding running test on pipeine --- .github/workflows/swift.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/swift.yml diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 0000000..81f6fef --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,26 @@ +# This workflow will build a Swift project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift + +name: Run Unit Tests + +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Swift + uses: swift-actions/setup-swift@v1 + with: + swift-version: '5.5' + + - name: Run tests + run: swift test +