diff --git a/.gitignore b/.gitignore index 14ccbf7..53288d2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,8 +11,9 @@ Thumbs.db *~ *.swp *.swo -.vscode/ .idea/ +.vscode/*.code-workspace +.vscode/settings.json # Logs *.log diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..c51d5fa --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,44 @@ +{ + "configurations": [ + { + "type": "swift", + "request": "launch", + "name": "Debug Mole", + "args": [], + "cwd": "${workspaceFolder}/app", + "target": "Mole", + "configuration": "debug", + "preLaunchTask": "swift: Build Debug Mole (app)" + }, + { + "type": "swift", + "request": "launch", + "name": "Release Mole", + "args": [], + "cwd": "${workspaceFolder}/app", + "target": "Mole", + "configuration": "release", + "preLaunchTask": "swift: Build Release Mole (app)" + }, + { + "type": "swift", + "request": "launch", + "args": [], + "cwd": "${workspaceFolder:Mole}/app", + "name": "Debug Mole (app)", + "target": "Mole", + "configuration": "debug", + "preLaunchTask": "swift: Build Debug Mole (app)" + }, + { + "type": "swift", + "request": "launch", + "args": [], + "cwd": "${workspaceFolder:Mole}/app", + "name": "Release Mole (app)", + "target": "Mole", + "configuration": "release", + "preLaunchTask": "swift: Build Release Mole (app)" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..3caae56 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,38 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "swift: Build Debug Mole (app)", + "type": "shell", + "command": "swift", + "args": ["build", "-c", "debug"], + "options": { + "cwd": "${workspaceFolder}/app" + }, + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "shared" + }, + "problemMatcher": ["$swiftc"] + }, + { + "label": "swift: Build Release Mole (app)", + "type": "shell", + "command": "swift", + "args": ["build", "-c", "release"], + "options": { + "cwd": "${workspaceFolder}/app" + }, + "group": "build", + "presentation": { + "reveal": "always", + "panel": "shared" + }, + "problemMatcher": ["$swiftc"] + } + ] +} diff --git a/app/Sources/Mole/AppListView.swift b/app/AppListView.swift similarity index 100% rename from app/Sources/Mole/AppListView.swift rename to app/AppListView.swift diff --git a/app/Sources/Mole/AppMode.swift b/app/AppMode.swift similarity index 100% rename from app/Sources/Mole/AppMode.swift rename to app/AppMode.swift diff --git a/app/Sources/Mole/AppState.swift b/app/AppState.swift similarity index 100% rename from app/Sources/Mole/AppState.swift rename to app/AppState.swift diff --git a/app/Sources/Mole/AuthContext.swift b/app/AuthContext.swift similarity index 100% rename from app/Sources/Mole/AuthContext.swift rename to app/AuthContext.swift diff --git a/app/Sources/Mole/ConfettiView.swift b/app/ConfettiView.swift similarity index 100% rename from app/Sources/Mole/ConfettiView.swift rename to app/ConfettiView.swift diff --git a/app/Sources/Mole/ContentView.swift b/app/ContentView.swift similarity index 100% rename from app/Sources/Mole/ContentView.swift rename to app/ContentView.swift diff --git a/app/Extensions.swift b/app/Extensions.swift new file mode 100644 index 0000000..4d89614 --- /dev/null +++ b/app/Extensions.swift @@ -0,0 +1,19 @@ +import AppKit + +extension Bundle { + /// Loads an image from the bundle's resources by name. + /// + /// This method attempts to load an image with the given name by trying + /// common image file extensions in order: PNG, JPG, and ICNS. + /// + /// - Parameter name: The name of the image resource without extension. + /// - Returns: An NSImage if found, nil otherwise. + /// + /// - Note: Supported formats: PNG, JPG, ICNS + func image(forResource name: String) -> NSImage? { + if let url = url(forResource: name, withExtension: "png") { return NSImage(contentsOf: url) } + if let url = url(forResource: name, withExtension: "jpg") { return NSImage(contentsOf: url) } + if let url = url(forResource: name, withExtension: "icns") { return NSImage(contentsOf: url) } + return nil + } +} diff --git a/app/Sources/Mole/KeychainHelper.swift b/app/KeychainHelper.swift similarity index 100% rename from app/Sources/Mole/KeychainHelper.swift rename to app/KeychainHelper.swift diff --git a/app/Sources/Mole/LogView.swift b/app/LogView.swift similarity index 100% rename from app/Sources/Mole/LogView.swift rename to app/LogView.swift diff --git a/app/Sources/Mole/MoleApp.swift b/app/MoleApp.swift similarity index 100% rename from app/Sources/Mole/MoleApp.swift rename to app/MoleApp.swift diff --git a/app/Sources/Mole/MoleSceneView.swift b/app/MoleSceneView.swift similarity index 94% rename from app/Sources/Mole/MoleSceneView.swift rename to app/MoleSceneView.swift index e32bd89..b94c538 100644 --- a/app/Sources/Mole/MoleSceneView.swift +++ b/app/MoleSceneView.swift @@ -119,12 +119,7 @@ struct MoleSceneView: NSViewRepresentable { } // Load Texture (Support PNG and JPG) - var finalImage: NSImage? - if let url = Bundle.module.url(forResource: textureName, withExtension: "png") { - finalImage = NSImage(contentsOf: url) - } else if let url = Bundle.module.url(forResource: textureName, withExtension: "jpg") { - finalImage = NSImage(contentsOf: url) - } + let finalImage = Bundle.module.image(forResource: textureName) if let image = finalImage { material.diffuse.contents = image diff --git a/app/Sources/Mole/MoleView.swift b/app/MoleView.swift similarity index 100% rename from app/Sources/Mole/MoleView.swift rename to app/MoleView.swift diff --git a/app/Sources/Mole/OptimizerService.swift b/app/OptimizerService.swift similarity index 100% rename from app/Sources/Mole/OptimizerService.swift rename to app/OptimizerService.swift diff --git a/app/Package.swift b/app/Package.swift index aac8858..69b7e32 100644 --- a/app/Package.swift +++ b/app/Package.swift @@ -12,6 +12,8 @@ let package = Package( targets: [ .executableTarget( name: "Mole", + path: ".", + exclude: ["Package.swift", "package.sh"], resources: [ .process("Resources") ] diff --git a/app/Sources/Mole/PasswordSheetView.swift b/app/PasswordSheetView.swift similarity index 97% rename from app/Sources/Mole/PasswordSheetView.swift rename to app/PasswordSheetView.swift index b4a4173..758f95e 100644 --- a/app/Sources/Mole/PasswordSheetView.swift +++ b/app/PasswordSheetView.swift @@ -42,10 +42,8 @@ struct PasswordSheetView: View { VStack(alignment: .leading, spacing: 14) { // Icon ZStack(alignment: .bottomTrailing) { - if let url = Bundle.module.url(forResource: "mole", withExtension: "png"), - let customIcon = NSImage(contentsOf: url) - { - Image(nsImage: customIcon) + if let icon = Bundle.module.image(forResource: "mole") { + Image(nsImage: icon) .resizable() .interpolation(.high) .aspectRatio(contentMode: .fit) diff --git a/app/Sources/Mole/Resources/earth.jpg b/app/Resources/earth.jpg similarity index 100% rename from app/Sources/Mole/Resources/earth.jpg rename to app/Resources/earth.jpg diff --git a/app/Sources/Mole/Resources/mars.png b/app/Resources/mars.png similarity index 100% rename from app/Sources/Mole/Resources/mars.png rename to app/Resources/mars.png diff --git a/app/Sources/Mole/Resources/mercury.png b/app/Resources/mercury.png similarity index 100% rename from app/Sources/Mole/Resources/mercury.png rename to app/Resources/mercury.png diff --git a/app/Resources/mole.icns b/app/Resources/mole.icns new file mode 100644 index 0000000..c8b2154 Binary files /dev/null and b/app/Resources/mole.icns differ diff --git a/app/Sources/Mole/ScannerService.swift b/app/ScannerService.swift similarity index 100% rename from app/Sources/Mole/ScannerService.swift rename to app/ScannerService.swift diff --git a/app/Sources/Mole/ShellRunner.swift b/app/ShellRunner.swift similarity index 100% rename from app/Sources/Mole/ShellRunner.swift rename to app/ShellRunner.swift diff --git a/app/Sources/Mole/Resources/mole.png b/app/Sources/Mole/Resources/mole.png deleted file mode 100644 index 6e5043f..0000000 Binary files a/app/Sources/Mole/Resources/mole.png and /dev/null differ diff --git a/app/Sources/Mole/Resources/neptune.png b/app/Sources/Mole/Resources/neptune.png deleted file mode 100644 index dfe60e4..0000000 Binary files a/app/Sources/Mole/Resources/neptune.png and /dev/null differ diff --git a/app/Sources/Mole/UninstallerService.swift b/app/UninstallerService.swift similarity index 100% rename from app/Sources/Mole/UninstallerService.swift rename to app/UninstallerService.swift diff --git a/app/package.sh b/app/package.sh index 0eae8c1..65634a6 100755 --- a/app/package.sh +++ b/app/package.sh @@ -6,7 +6,7 @@ APP_NAME="Mole" # Get the actual build path dynamically BUILD_PATH="$(swift build -c release --show-bin-path)/$APP_NAME" APP_BUNDLE="$APP_NAME.app" -ICON_SOURCE="Sources/Mole/Resources/mole.png" +ICON_SOURCE="Resources/mole.icns" echo "🚀 Building Release Binary..." swift build -c release @@ -46,29 +46,8 @@ cat < "$APP_BUNDLE/Contents/Info.plist" EOF if [ -f "$ICON_SOURCE" ]; then - echo "🎨 Generating App Icon from $ICON_SOURCE..." - ICONSET="Mole.iconset" - mkdir -p "$ICONSET" - - # Resize images for standard icon sizes - sips -z 16 16 "$ICON_SOURCE" --out "$ICONSET/icon_16x16.png" > /dev/null - sips -z 32 32 "$ICON_SOURCE" --out "$ICONSET/icon_16x16@2x.png" > /dev/null - sips -z 32 32 "$ICON_SOURCE" --out "$ICONSET/icon_32x32.png" > /dev/null - sips -z 64 64 "$ICON_SOURCE" --out "$ICONSET/icon_32x32@2x.png" > /dev/null - sips -z 128 128 "$ICON_SOURCE" --out "$ICONSET/icon_128x128.png" > /dev/null - sips -z 256 256 "$ICON_SOURCE" --out "$ICONSET/icon_128x128@2x.png" > /dev/null - sips -z 256 256 "$ICON_SOURCE" --out "$ICONSET/icon_256x256.png" > /dev/null - sips -z 512 512 "$ICON_SOURCE" --out "$ICONSET/icon_256x256@2x.png" > /dev/null - sips -z 512 512 "$ICON_SOURCE" --out "$ICONSET/icon_512x512.png" > /dev/null - sips -z 1024 1024 "$ICON_SOURCE" --out "$ICONSET/icon_512x512@2x.png" > /dev/null - - # Convert to icns - iconutil -c icns "$ICONSET" - mv "Mole.icns" "$APP_BUNDLE/Contents/Resources/AppIcon.icns" - - # Clean up - rm -rf "$ICONSET" - + echo "🎨 Copying App Icon from $ICON_SOURCE..." + cp "$ICON_SOURCE" "$APP_BUNDLE/Contents/Resources/AppIcon.icns" echo "✅ App Icon set successfully." else echo "⚠️ Icon file not found at $ICON_SOURCE. App will use default icon."