diff --git a/App/Info.plist b/App/Info.plist index c868e2c..7ef6c7e 100644 --- a/App/Info.plist +++ b/App/Info.plist @@ -10,8 +10,15 @@ $(EXECUTABLE_NAME) CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleIconName + AppIcon CFBundleInfoDictionaryVersion 6.0 + CFBundleLocalizations + + en + de + CFBundleName $(PRODUCT_NAME) CFBundlePackageType diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json b/App/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..7e1a770 --- /dev/null +++ b/App/Resources/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,15 @@ +{ + "images" : [ + { "filename" : "icon_16x16.png", "idiom" : "mac", "scale" : "1x", "size" : "16x16" }, + { "filename" : "icon_16x16@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "16x16" }, + { "filename" : "icon_32x32.png", "idiom" : "mac", "scale" : "1x", "size" : "32x32" }, + { "filename" : "icon_32x32@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "32x32" }, + { "filename" : "icon_128x128.png", "idiom" : "mac", "scale" : "1x", "size" : "128x128" }, + { "filename" : "icon_128x128@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "128x128" }, + { "filename" : "icon_256x256.png", "idiom" : "mac", "scale" : "1x", "size" : "256x256" }, + { "filename" : "icon_256x256@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "256x256" }, + { "filename" : "icon_512x512.png", "idiom" : "mac", "scale" : "1x", "size" : "512x512" }, + { "filename" : "icon_512x512@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "512x512" } + ], + "info" : { "author" : "xcode", "version" : 1 } +} diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128.png new file mode 100644 index 0000000..d76b879 Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128.png differ diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png new file mode 100644 index 0000000..0ee2c57 Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png differ diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16.png new file mode 100644 index 0000000..26229e0 Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16.png differ diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png new file mode 100644 index 0000000..a44c145 Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png differ diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256.png new file mode 100644 index 0000000..0ee2c57 Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256.png differ diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png new file mode 100644 index 0000000..3544a9d Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png differ diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32.png new file mode 100644 index 0000000..a44c145 Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32.png differ diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png new file mode 100644 index 0000000..9275c42 Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png differ diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512.png new file mode 100644 index 0000000..3544a9d Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512.png differ diff --git a/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png new file mode 100644 index 0000000..cef9436 Binary files /dev/null and b/App/Resources/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png differ diff --git a/App/Resources/Assets.xcassets/Contents.json b/App/Resources/Assets.xcassets/Contents.json new file mode 100644 index 0000000..d8b757a --- /dev/null +++ b/App/Resources/Assets.xcassets/Contents.json @@ -0,0 +1,3 @@ +{ + "info" : { "author" : "xcode", "version" : 1 } +} diff --git a/Makefile b/Makefile index 69b43b5..9887022 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,11 @@ PROJECT := Sprachmittler.xcodeproj SCHEME := Sprachmittler DERIVED := .build/xcode APP_PATH := $(DERIVED)/Build/Products/Debug/Sprachmittler.app +RELEASE_APP := .build/xcode-release/Build/Products/Release/Sprachmittler.app INSTALL_DIR ?= /Applications +DMG_DIR ?= dist -.PHONY: bootstrap doctor generate build build-pkg build-app test live-test verify app install release fixtures smoke privacy-check format manifest clean +.PHONY: bootstrap doctor generate build build-pkg build-app test live-test verify app install release-build dmg release icon fixtures smoke privacy-check format manifest clean bootstrap: @scripts/bootstrap.sh @@ -17,6 +19,9 @@ doctor: generate: xcodegen generate --spec project.yml +icon: + swift scripts/generate-app-icon.swift + build: build-pkg build-app build-pkg: @@ -42,14 +47,26 @@ app: build-app release: @scripts/release.sh --dry-run -install: build-app +release-build: generate + xcodebuild -project $(PROJECT) -scheme $(SCHEME) -configuration Release \ + -derivedDataPath .build/xcode-release -destination 'platform=macOS,arch=arm64' -quiet build + +# Build Release, replace $(INSTALL_DIR)/Sprachmittler.app and start it. Not `cp -r`: ditto keeps +# symlinks and attributes. Remove the old copy first, because ditto merges. +install: release-build + @test -d "$(RELEASE_APP)" || { echo "error: $(RELEASE_APP) not found"; exit 1; } + @test -d "$(INSTALL_DIR)" || { echo "error: $(INSTALL_DIR) does not exist"; exit 1; } + scripts/check-signature.sh "$(RELEASE_APP)" install @pkill -x Sprachmittler 2>/dev/null || true - ditto "$(APP_PATH)" "$(INSTALL_DIR)/Sprachmittler.app" - codesign --force --sign - --options runtime \ - --entitlements App/Sprachmittler.entitlements "$(INSTALL_DIR)/Sprachmittler.app" + rm -rf "$(INSTALL_DIR)/Sprachmittler.app" + ditto "$(RELEASE_APP)" "$(INSTALL_DIR)/Sprachmittler.app" scripts/check-signature.sh "$(INSTALL_DIR)/Sprachmittler.app" install open "$(INSTALL_DIR)/Sprachmittler.app" +# Local, unnotarised DMG from the same Release build. Use scripts/release.sh for distribution. +dmg: release-build + @DMG_DIR="$(DMG_DIR)" scripts/make-dmg.sh + fixtures: @scripts/capture-fixtures.sh diff --git a/README.md b/README.md index c6dc8ae..a148a84 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,11 @@ make bootstrap # installs xcodegen, swif ollama pull hf.co/tencent/Hy-MT3-7B-GGUF:Q4_K_M # about 5.15 GB make smoke # translates one fixed synthetic sentence make doctor # checks OpenCode 2.x and the resolved V2 config -make verify # the scaffold should already build and test -make app # builds and launches Sprachmittler.app +make verify # format, lint, privacy, tests, Debug + Release builds +make app # builds and launches the Debug app +make install # builds Release, installs in /Applications and launches +make dmg # local unnotarised DMG from the Release build +make icon # regenerate the app icon assets opencode # start OpenCode in the repo root ``` diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 69aa9d8..476b2c1 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -607,7 +607,7 @@ Never store source text, translations, pasteboard contents or app names in setti | Sandbox | **Off** (ADR-003): Accessibility replacement. Hardened Runtime **on**, no exceptions | | Signing | Development: "Sign to Run Locally". Release: Developer ID + notarisation | | ATS | `NSAllowsLocalNetworking = YES`; remote endpoints must be HTTPS | -| Distribution | Signed, notarised DMG; Mac App Store not in v1 | +| Distribution | Signed, notarised DMG; local `make dmg` for testing; Mac App Store not in v1 | `make install` copies the app to `/Applications` and ad-hoc signs it. macOS ties Accessibility permission to the app's signature and location; after a reinstall the user may have to remove and re-add the app in System Settings. diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 3337f7a..95cd4fc 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -149,3 +149,4 @@ Legend: `[ ]` open · `[~]` in progress · `[x]` done · `[!]` blocked (explain) 2026-11-26 · T8.4 · Added English/German `Localizable.strings` for the app shell and `docs/USER_GUIDE.md` (install, permissions, privacy, troubleshooting). 2026-11-26 · T8.5 · Added `scripts/release.sh` (archive unsigned, Developer ID sign, notarise/staple, DMG, `--dry-run`) and `make release`. 2026-11-26 · T8.6 · The compatibility matrix remains a manual 10-app pass; no untested cell is claimed. +2026-11-26 · T8.5 · Added a sibling-family app icon (`make icon`), `CFBundleIconName`/asset catalog wiring, `make install` from the Release build, and `make dmg`/`scripts/make-dmg.sh` with a mounted-image signature check. Dry-run release and local DMG/install were verified. diff --git a/project.yml b/project.yml index 0690ca6..1872ced 100644 --- a/project.yml +++ b/project.yml @@ -53,6 +53,7 @@ targets: CODE_SIGN_IDENTITY: "-" # "Sign to Run Locally" for development ENABLE_APP_SANDBOX: NO # ADR-003: Accessibility insertion needs it off COMBINE_HIDPI_IMAGES: YES + ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon dependencies: - package: SprachmittlerKit product: SprachmittlerCore diff --git a/scripts/generate-app-icon.swift b/scripts/generate-app-icon.swift new file mode 100755 index 0000000..bd1c2be --- /dev/null +++ b/scripts/generate-app-icon.swift @@ -0,0 +1,357 @@ +#!/usr/bin/env swift +// Generates App/Resources/Assets.xcassets/AppIcon.appiconset from vector geometry. +// +// Run with `make icon` (or `swift scripts/generate-app-icon.swift`). PNGs are committed, so +// `make verify` does not depend on this script. +// +// Family geometry follows Vorleser and Schriftleser: 1024 canvas, 824 opaque indigo tile, +// transparent margin, soft shadow. The translation motif is two facing speech bubbles carrying +// text bars; small sizes simplify to one bubble for legibility. + +import CoreGraphics +import Foundation +import ImageIO +import UniformTypeIdentifiers + +private enum Design { + static let canvas: CGFloat = 1024 + static let tileInset: CGFloat = 100 + static let tileSize = canvas - tileInset * 2 + static let tileRadius = tileSize * 0.2245 + + // Same indigo family tile as Vorleser and Schriftleser. + static let gradientTop = srgb(0x5B, 0x7C, 0xFA) + static let gradientBottom = srgb(0x2E, 0x3F, 0xC7) + static let glyph = srgb(0xFF, 0xFF, 0xFF) + static let bar = srgb(0x2F, 0x3E, 0xC4) + + static func srgb(_ r: UInt8, _ g: UInt8, _ b: UInt8) -> CGColor { + CGColor( + colorSpace: CGColorSpace(name: CGColorSpace.sRGB)!, + components: [CGFloat(r) / 255, CGFloat(g) / 255, CGFloat(b) / 255, 1] + )! + } +} + +private struct Bubble { + let rect: CGRect + let radius: CGFloat + let tail: [CGPoint] + let bars: [CGFloat] + let barHeight: CGFloat + let barGap: CGFloat + let fill: CGColor + let barColor: CGColor +} + +private struct Layout { + let size: Int + let scale: CGFloat + let tile: CGRect + let tileRadius: CGFloat + let bubbles: [Bubble] + let shadow: (offset: CGSize, blur: CGFloat, opacity: CGFloat)? + + init(size: Int) { + self.size = size + scale = CGFloat(size) / Design.canvas + tile = CGRect(x: Design.tileInset, y: Design.tileInset, width: Design.tileSize, height: Design.tileSize) + tileRadius = Design.tileRadius + + let simplified = size <= 32 + let barThickness = Design.canvas * (simplified ? 0.075 : 0.045) + let barGap = barThickness * (simplified ? 1.15 : 0.85) + let tailStroke = Design.canvas * (simplified ? 0.05 : 0.030) + + if simplified { + let width = tile.width * 0.76 + let height = tile.height * 0.56 + let rect = CGRect( + x: tile.midX - width / 2, + y: tile.minY + tile.height * 0.52 - height / 2, + width: width, + height: height + ) + let tail = [ + CGPoint(x: rect.minX + width * 0.24, y: rect.minY + barThickness * 0.8), + CGPoint(x: rect.minX + width * 0.10, y: rect.minY - height * 0.13), + CGPoint(x: rect.minX + width * 0.44, y: rect.minY + barThickness * 0.8), + ] + bubbles = [ + Bubble( + rect: rect, + radius: height * 0.26, + tail: tail, + bars: [width * 0.62, width * 0.40], + barHeight: barThickness, + barGap: barGap, + fill: Design.glyph, + barColor: Design.bar + ), + ] + } else { + let backWidth = tile.width * 0.56 + let backHeight = tile.height * 0.33 + let backRect = CGRect( + x: tile.minX + tile.width * 0.06, + y: tile.minY + tile.height * 0.34, + width: backWidth, + height: backHeight + ) + let backTail = [ + CGPoint(x: backRect.minX + backWidth * 0.18, y: backRect.minY + tailStroke * 0.7), + CGPoint(x: backRect.minX + backWidth * 0.02, y: backRect.minY - backHeight * 0.16), + CGPoint(x: backRect.minX + backWidth * 0.40, y: backRect.minY + tailStroke * 0.7), + ] + let back = Bubble( + rect: backRect, + radius: backHeight * 0.26, + tail: backTail, + bars: [backWidth * 0.62, backWidth * 0.45, backWidth * 0.30], + barHeight: barThickness, + barGap: barGap, + fill: Design.bar, + barColor: Design.glyph + ) + + let frontWidth = tile.width * 0.48 + let frontHeight = tile.height * 0.30 + let frontRect = CGRect( + x: tile.maxX - tile.width * 0.06 - frontWidth, + y: tile.minY + tile.height * 0.18, + width: frontWidth, + height: frontHeight + ) + let frontTail = [ + CGPoint(x: frontRect.maxX - frontWidth * 0.18, y: frontRect.minY + tailStroke * 0.7), + CGPoint(x: frontRect.maxX - frontWidth * 0.02, y: frontRect.minY - frontHeight * 0.16), + CGPoint(x: frontRect.maxX - frontWidth * 0.40, y: frontRect.minY + tailStroke * 0.7), + ] + let front = Bubble( + rect: frontRect, + radius: frontHeight * 0.26, + tail: frontTail, + bars: [frontWidth * 0.62, frontWidth * 0.40], + barHeight: barThickness, + barGap: barGap, + fill: Design.glyph, + barColor: Design.bar + ) + bubbles = [back, front] + } + + shadow = size >= 128 ? (CGSize(width: 0, height: -8), 26, 0.32) : nil + } +} + +private func roundedRect(_ rect: CGRect, _ radius: CGFloat) -> CGPath { + CGPath(roundedRect: rect, cornerWidth: radius, cornerHeight: radius, transform: nil) +} + +private func render(size: Int) -> CGImage? { + let layout = Layout(size: size) + let colorSpace = CGColorSpace(name: CGColorSpace.sRGB)! + guard let context = CGContext( + data: nil, + width: size, + height: size, + bitsPerComponent: 8, + bytesPerRow: 0, + space: colorSpace, + bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue + ) else { return nil } + + context.setAllowsAntialiasing(true) + context.setShouldAntialias(true) + context.interpolationQuality = .high + context.clear(CGRect(x: 0, y: 0, width: size, height: size)) + context.scaleBy(x: layout.scale, y: layout.scale) + + let tilePath = roundedRect(layout.tile, layout.tileRadius) + context.saveGState() + if let shadow = layout.shadow { + context.setShadow( + offset: shadow.offset, + blur: shadow.blur, + color: CGColor(colorSpace: colorSpace, components: [0, 0, 0, shadow.opacity]) + ) + } + context.addPath(tilePath) + context.setFillColor(Design.gradientBottom) + context.fillPath() + context.restoreGState() + + let gradient = CGGradient( + colorsSpace: colorSpace, + colors: [Design.gradientTop, Design.gradientBottom] as CFArray, + locations: [0, 1] + )! + context.saveGState() + context.addPath(tilePath) + context.clip() + context.drawLinearGradient( + gradient, + start: CGPoint(x: layout.tile.midX, y: layout.tile.maxY), + end: CGPoint(x: layout.tile.midX, y: layout.tile.minY), + options: [] + ) + context.restoreGState() + + for bubble in layout.bubbles { + context.setFillColor(bubble.fill) + context.beginPath() + context.addLines(between: bubble.tail) + context.closePath() + context.fillPath() + context.addPath(roundedRect(bubble.rect, bubble.radius)) + context.fillPath() + + let totalHeight = CGFloat(bubble.bars.count) * bubble.barHeight + + CGFloat(bubble.bars.count - 1) * bubble.barGap + var y = bubble.rect.midY + totalHeight / 2 - bubble.barHeight + let x = bubble.rect.minX + bubble.rect.width * 0.16 + context.setFillColor(bubble.barColor) + for width in bubble.bars { + context.addPath(roundedRect( + CGRect(x: x, y: y, width: width, height: bubble.barHeight), + bubble.barHeight / 2 + )) + context.fillPath() + y -= bubble.barHeight + bubble.barGap + } + } + + return context.makeImage() +} + +private let slots: [(name: String, pixels: Int)] = [ + ("icon_16x16.png", 16), + ("icon_16x16@2x.png", 32), + ("icon_32x32.png", 32), + ("icon_32x32@2x.png", 64), + ("icon_128x128.png", 128), + ("icon_128x128@2x.png", 256), + ("icon_256x256.png", 256), + ("icon_256x256@2x.png", 512), + ("icon_512x512.png", 512), + ("icon_512x512@2x.png", 1024), +] + +private let contents = """ +{ + "images" : [ + { "filename" : "icon_16x16.png", "idiom" : "mac", "scale" : "1x", "size" : "16x16" }, + { "filename" : "icon_16x16@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "16x16" }, + { "filename" : "icon_32x32.png", "idiom" : "mac", "scale" : "1x", "size" : "32x32" }, + { "filename" : "icon_32x32@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "32x32" }, + { "filename" : "icon_128x128.png", "idiom" : "mac", "scale" : "1x", "size" : "128x128" }, + { "filename" : "icon_128x128@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "128x128" }, + { "filename" : "icon_256x256.png", "idiom" : "mac", "scale" : "1x", "size" : "256x256" }, + { "filename" : "icon_256x256@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "256x256" }, + { "filename" : "icon_512x512.png", "idiom" : "mac", "scale" : "1x", "size" : "512x512" }, + { "filename" : "icon_512x512@2x.png", "idiom" : "mac", "scale" : "2x", "size" : "512x512" } + ], + "info" : { "author" : "xcode", "version" : 1 } +} + +""" + +private let assetCatalogContents = """ +{ + "info" : { "author" : "xcode", "version" : 1 } +} + +""" + +private func writePNG(_ image: CGImage, to url: URL) throws { + guard let destination = CGImageDestinationCreateWithURL( + url as CFURL, + UTType.png.identifier as CFString, + 1, + nil + ) else { + throw NSError(domain: "icon", code: 1, userInfo: [NSLocalizedDescriptionKey: "cannot write \(url.path)"]) + } + CGImageDestinationAddImage(destination, image, nil) + guard CGImageDestinationFinalize(destination) else { + throw NSError(domain: "icon", code: 2, userInfo: [NSLocalizedDescriptionKey: "cannot finish \(url.path)"]) + } +} + +private func writePreview(to url: URL) throws { + let width = 1240 + let height = 640 + let colorSpace = CGColorSpace(name: CGColorSpace.sRGB)! + guard let context = CGContext( + data: nil, + width: width, + height: height, + bitsPerComponent: 8, + bytesPerRow: 0, + space: colorSpace, + bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue + ) else { return } + + context.setFillColor(Design.srgb(0xEC, 0xEC, 0xEE)) + context.fill(CGRect(x: 0, y: 0, width: width, height: height / 2)) + context.setFillColor(Design.srgb(0x1C, 0x1C, 0x1E)) + context.fill(CGRect(x: 0, y: height / 2, width: width, height: height / 2)) + + var x = 40 + for size in [16, 32, 64, 128, 256] { + if let image = render(size: size) { + context.draw(image, in: CGRect(x: x, y: height / 2 + 40, width: size, height: size)) + context.draw(image, in: CGRect(x: x, y: 40, width: size, height: size)) + } + x += size + 50 + } + + x += 20 + for size in [16, 32] { + guard let image = render(size: size) else { continue } + let scale = 8 + let side = size * scale + context.saveGState() + context.interpolationQuality = .none + context.draw(image, in: CGRect(x: x, y: height / 2 - side / 2, width: side, height: side)) + context.restoreGState() + x += side + 40 + } + + guard let image = context.makeImage() else { return } + try writePNG(image, to: url) +} + +private let root = URL(fileURLWithPath: #filePath) + .deletingLastPathComponent() + .deletingLastPathComponent() +private let assetCatalog = root + .appendingPathComponent("App/Resources/Assets.xcassets", isDirectory: true) +private let iconSet = assetCatalog.appendingPathComponent("AppIcon.appiconset", isDirectory: true) + +do { + try FileManager.default.createDirectory(at: iconSet, withIntermediateDirectories: true) + try assetCatalogContents.write( + to: assetCatalog.appendingPathComponent("Contents.json"), + atomically: true, + encoding: .utf8 + ) + try contents.write(to: iconSet.appendingPathComponent("Contents.json"), atomically: true, encoding: .utf8) + + for slot in slots { + guard let image = render(size: slot.pixels) else { + throw NSError(domain: "icon", code: 3, userInfo: [NSLocalizedDescriptionKey: "render failed at \(slot.pixels)"]) + } + try writePNG(image, to: iconSet.appendingPathComponent(slot.name)) + } + + let previewDirectory = root.appendingPathComponent(".build", isDirectory: true) + try FileManager.default.createDirectory(at: previewDirectory, withIntermediateDirectories: true) + try writePreview(to: previewDirectory.appendingPathComponent("icon-preview.png")) + + print("wrote \(slots.count) icons to \(iconSet.path)") + print("preview: \(previewDirectory.appendingPathComponent("icon-preview.png").path)") +} catch { + FileHandle.standardError.write(Data("error: \(error.localizedDescription)\n".utf8)) + exit(1) +} diff --git a/scripts/make-dmg.sh b/scripts/make-dmg.sh new file mode 100755 index 0000000..a52ffff --- /dev/null +++ b/scripts/make-dmg.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# Build a local, unnotarised DMG from the Release build. For testing/internal sharing only; use +# scripts/release.sh for a Developer ID signed and notarised distribution image. +set -euo pipefail +cd "$(dirname "$0")/.." + +app="Sprachmittler" +release_app=".build/xcode-release/Build/Products/Release/$app.app" +dist="${DMG_DIR:-dist}" + +[[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" ]] \ + || { echo "error: Sprachmittler requires an Apple Silicon Mac" >&2; exit 1; } +[[ -d "$release_app" ]] || { echo "error: $release_app not found — run 'make release-build'" >&2; exit 1; } + +step() { printf '\n\033[1m▶ %s\033[0m\n' "$*"; } + +check_app() { + local candidate="$1" + scripts/check-signature.sh "$candidate" install +} + +step "Check Release build" +check_app "$release_app" +version=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$release_app/Contents/Info.plist") +[[ -n "$version" ]] || { echo "error: cannot read CFBundleShortVersionString" >&2; exit 1; } +dmg="$dist/$app-$version-local.dmg" + +stage=$(mktemp -d) +mountpoint=$(mktemp -d) +mounted=0 +cleanup() { + if [[ $mounted -eq 1 ]]; then hdiutil detach "$mountpoint" -quiet || true; fi + rm -rf "$stage" "$mountpoint" +} +trap cleanup EXIT + +step "Stage $app $version" +ditto "$release_app" "$stage/$app.app" +ln -s /Applications "$stage/Applications" + +step "Create $dmg" +mkdir -p "$dist" +rm -f "$dmg" +if diskutil image create from --help >/dev/null 2>&1; then + if ! output=$(diskutil image create from "$stage" "$dmg" --volumeName "$app" --format UDZO 2>&1); then + printf '%s\n' "$output" >&2 + exit 1 + fi +else + hdiutil create -volname "$app" -srcfolder "$stage" -ov -format UDZO "$dmg" >/dev/null +fi +hdiutil verify "$dmg" >/dev/null + +step "Verify mounted image" +hdiutil attach "$dmg" -readonly -nobrowse -noautoopen -quiet -mountpoint "$mountpoint" +mounted=1 +check_app "$mountpoint/$app.app" +[[ -L "$mountpoint/Applications" ]] \ + || { echo "error: Applications link missing from the image" >&2; exit 1; } +hdiutil detach "$mountpoint" -quiet +mounted=0 + +printf '\n\033[32m✔ %s\033[0m\n' "$dmg" +printf ' size %s\n' "$(du -h "$dmg" | cut -f1)" +printf ' sha256 %s\n' "$(shasum -a 256 "$dmg" | cut -d' ' -f1)" +cat <<'TXT' + +Ad-hoc signed and not notarised: this image is for testing and internal sharing only. +On another Mac, open it via right-click ▸ Open (or System Settings ▸ Privacy & Security ▸ Open Anyway). +For distribution use scripts/release.sh with a Developer ID identity and a notarytool profile. +TXT