Skip to content

A native macOS app for managing virtual iPhones - browse, create, and boot iOS research VMs from a single window.

Swift

General: Add SwiftPM package, app bundling, and icon

zqxwce04af9c4d34f4
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e9c4e57
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.build/
+.swiftpm/
+*.xcodeproj
+.superpowers/
+.DS_Store
+.vscode/
diff --git a/Package.swift b/Package.swift
new file mode 100644
index 0000000..e19d6d6
--- /dev/null
+++ b/Package.swift
@@ -0,0 +1,18 @@
+// swift-tools-version: 6.0
+import PackageDescription
+
+let package = Package(
+ name: "vphone-ws",
+ platforms: [.macOS(.v15)],
+ targets: [
+ .target(name: "VPhoneWSCore", path: "Sources/VPhoneWSCore"),
+ .executableTarget(
+ name: "vphone-ws",
+ dependencies: ["VPhoneWSCore"],
+ path: "Sources/vphone-ws"),
+ .testTarget(
+ name: "VPhoneWSCoreTests",
+ dependencies: ["VPhoneWSCore"],
+ path: "tests/VPhoneWSCoreTests"),
+ ]
+)
diff --git a/Resources/AppIcon.icns b/Resources/AppIcon.icns
new file mode 100644
index 0000000..e425709
Binary files /dev/null and b/Resources/AppIcon.icns differ
diff --git a/Resources/Info.plist b/Resources/Info.plist
new file mode 100644
index 0000000..6ac2a59
--- /dev/null
+++ b/Resources/Info.plist
@@ -0,0 +1,16 @@
+<?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>CFBundleName</key><string>vPhone Workstation</string>
+ <key>CFBundleIdentifier</key><string>com.vphone.ws</string>
+ <key>CFBundleExecutable</key><string>vphone-ws</string>
+ <key>CFBundleIconFile</key><string>AppIcon</string>
+ <key>CFBundleIconName</key><string>AppIcon</string>
+ <key>CFBundlePackageType</key><string>APPL</string>
+ <key>CFBundleShortVersionString</key><string>0.1.0</string>
+ <key>CFBundleVersion</key><string>1</string>
+ <key>LSMinimumSystemVersion</key><string>15.0</string>
+ <key>NSHighResolutionCapable</key><true/>
+</dict>
+</plist>
diff --git a/scripts/bundle.sh b/scripts/bundle.sh
new file mode 100755
index 0000000..0ae0729
--- /dev/null
+++ b/scripts/bundle.sh
@@ -0,0 +1,11 @@
+#!/bin/zsh
+set -euo pipefail
+cd "${0:a:h}/.."
+swift build -c release
+APP=".build/vphone-ws.app"
+rm -rf "$APP"
+mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
+cp Resources/Info.plist "$APP/Contents/Info.plist"
+cp Resources/AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"
+cp .build/release/vphone-ws "$APP/Contents/MacOS/vphone-ws"
+echo "built $APP"
diff --git a/scripts/frame_shot.swift b/scripts/frame_shot.swift
new file mode 100644
index 0000000..423456e
--- /dev/null
+++ b/scripts/frame_shot.swift
@@ -0,0 +1,47 @@
+// Frames a raw window screenshot for docs: rounded corners + soft drop shadow
+// on transparent padding, so it reads cleanly on light or dark READMEs.
+// Usage: swift scripts/frame_shot.swift <in.png> <out.png>
+import AppKit
+import CoreGraphics
+
+let args = CommandLine.arguments
+guard args.count >= 3 else { fputs("usage: frame_shot <in.png> <out.png>\n", stderr); exit(1) }
+
+guard let src = NSImage(contentsOf: URL(fileURLWithPath: args[1])),
+ let cg = src.cgImage(forProposedRect: nil, context: nil, hints: nil) else {
+ fputs("cannot load \(args[1])\n", stderr); exit(1)
+}
+
+let w = CGFloat(cg.width), h = CGFloat(cg.height)
+let pad: CGFloat = 64, radius: CGFloat = 16
+let W = Int(w + pad * 2), H = Int(h + pad * 2)
+let csp = CGColorSpaceCreateDeviceRGB()
+let ctx = CGContext(data: nil, width: W, height: H, bitsPerComponent: 8, bytesPerRow: 0,
+ space: csp, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)!
+func color(_ r: CGFloat, _ g: CGFloat, _ b: CGFloat, _ a: CGFloat) -> CGColor {
+ CGColor(colorSpace: csp, components: [r, g, b, a])!
+}
+
+let rect = CGRect(x: pad, y: pad, width: w, height: h)
+let path = CGPath(roundedRect: rect, cornerWidth: radius, cornerHeight: radius, transform: nil)
+
+// Shadow pass — fill the rounded rect so it casts a soft shadow onto the transparent ground.
+ctx.saveGState()
+ctx.setShadow(offset: CGSize(width: 0, height: -22), blur: 48, color: color(0, 0, 0, 0.42))
+ctx.addPath(path); ctx.setFillColor(color(0.06, 0.07, 0.09, 1)); ctx.fillPath()
+ctx.restoreGState()
+
+// Image pass — clip to the rounded rect and draw the shot (upright as-is in a bottom-up context).
+ctx.saveGState()
+ctx.addPath(path); ctx.clip()
+ctx.draw(cg, in: rect)
+ctx.restoreGState()
+
+// Hairline inner border for crispness.
+ctx.addPath(CGPath(roundedRect: rect.insetBy(dx: 0.5, dy: 0.5),
+ cornerWidth: radius, cornerHeight: radius, transform: nil))
+ctx.setStrokeColor(color(1, 1, 1, 0.07)); ctx.setLineWidth(1); ctx.strokePath()
+
+let rep = NSBitmapImageRep(cgImage: ctx.makeImage()!)
+try! rep.representation(using: .png, properties: [:])!.write(to: URL(fileURLWithPath: args[2]))
+print("wrote \(args[2])")
diff --git a/scripts/make_icon.swift b/scripts/make_icon.swift
new file mode 100644
index 0000000..459e712
--- /dev/null
+++ b/scripts/make_icon.swift
@@ -0,0 +1,59 @@
+// Generates the vPhone Workstation app icon (1024²).
+// Bold bright-blue phone outline + green corner status badge over a bright
+// white backdrop of vphone commands. Drawn in CoreGraphics/CoreText — no SVG tooling.
+// Usage: swift scripts/make_icon.swift <output.png>
+import AppKit
+import CoreGraphics
+import CoreText
+
+let out = CommandLine.arguments.count > 1 ? CommandLine.arguments[1] : "icon_1024.png"
+let S: CGFloat = 1024
+let csp = CGColorSpaceCreateDeviceRGB()
+let ctx = CGContext(data: nil, width: 1024, height: 1024, bitsPerComponent: 8, bytesPerRow: 0,
+ space: csp, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)!
+
+func c(_ r: Int, _ g: Int, _ b: Int, _ a: CGFloat = 1) -> CGColor {
+ CGColor(colorSpace: csp, components: [CGFloat(r)/255, CGFloat(g)/255, CGFloat(b)/255, a])!
+}
+// SVG (top-down) rect → CoreGraphics (bottom-up) rounded-rect path.
+func rr(_ x: CGFloat, _ y: CGFloat, _ w: CGFloat, _ h: CGFloat, _ rad: CGFloat) -> CGPath {
+ CGPath(roundedRect: CGRect(x: x, y: S - y - h, width: w, height: h), cornerWidth: rad, cornerHeight: rad, transform: nil)
+}
+func fill(_ p: CGPath, _ col: CGColor) { ctx.addPath(p); ctx.setFillColor(col); ctx.fillPath() }
+func strokeP(_ p: CGPath, _ col: CGColor, _ lw: CGFloat) { ctx.addPath(p); ctx.setStrokeColor(col); ctx.setLineWidth(lw); ctx.strokePath() }
+
+// Ground squircle + vertical gradient (clip stays on for the transcript).
+let sq = rr(0, 0, 1024, 1024, 230)
+ctx.saveGState(); ctx.addPath(sq); ctx.clip()
+let grad = CGGradient(colorsSpace: csp, colors: [c(15, 20, 32), c(6, 9, 14)] as CFArray, locations: [0, 1])!
+ctx.drawLinearGradient(grad, start: CGPoint(x: 0, y: 1024), end: .zero, options: [])
+
+// Command backdrop — bright white mono, clipped to the squircle.
+let font = NSFont.monospacedSystemFont(ofSize: 100, weight: .regular)
+let lines: [(String, CGFloat, CGFloat)] = [
+ ("$ vphone-cli", 52, 290), ("vm create 27b4", 52, 418), ("[+] fw patch jb", 52, 546),
+ ("=== restore ===", 52, 674), ("[+] first boot", 52, 802), ("$ vm launch", 52, 930),
+]
+ctx.textMatrix = .identity
+let textAttrs: [NSAttributedString.Key: Any] = [
+ .font: font,
+ NSAttributedString.Key(kCTForegroundColorAttributeName as String): c(255, 255, 255, 0.85),
+]
+for (s, x, ybase) in lines {
+ let line = CTLineCreateWithAttributedString(NSAttributedString(string: s, attributes: textAttrs))
+ ctx.textPosition = CGPoint(x: x, y: S - ybase)
+ CTLineDraw(line, ctx)
+}
+ctx.restoreGState()
+
+// Opaque phone outline over the text.
+fill(rr(356, 182, 312, 660, 84), c(11, 15, 24))
+strokeP(rr(356, 182, 312, 660, 84), c(91, 155, 255), 30)
+fill(rr(466, 252, 92, 26, 13), c(106, 166, 255))
+
+// Green corner status badge (SVG cx=810 cy=210 r=88).
+fill(CGPath(ellipseIn: CGRect(x: 810 - 88, y: (S - 210) - 88, width: 176, height: 176), transform: nil), c(63, 211, 90))
+
+let rep = NSBitmapImageRep(cgImage: ctx.makeImage()!)
+try! rep.representation(using: .png, properties: [:])!.write(to: URL(fileURLWithPath: out))
+print("wrote \(out)")