Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
Mac launcher uses the Liquid Glass app icon
v0lumehi760e1313d472
diff --git a/.github/workflows/build-mac-app.yml b/.github/workflows/build-mac-app.ymlindex 297d2771..004cf385 100644--- a/.github/workflows/build-mac-app.yml+++ b/.github/workflows/build-mac-app.yml@@ -101,7 +101,13 @@ jobs:rm -rf "$APP"mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"cp .build/release/NSPortBuilder "$APP/Contents/MacOS/NSPortBuilder"- cp AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"+ # The app icon is AppIcon.icon (Icon Composer). actool, from the runner's Xcode (26 or later), compiles it to Assets.car for+ # macOS 26 and later (Liquid Glass) and to AppIcon.icns for macOS 13 to 25. Info.plist names both (CFBundleIconName, CFBundleIconFile).+ ICON_OUT="$RUNNER_TEMP/app-icon"+ rm -rf "$ICON_OUT"; mkdir -p "$ICON_OUT"+ xcrun actool AppIcon.icon --compile "$ICON_OUT" --platform macosx --minimum-deployment-target 13.0 \+ --app-icon AppIcon --output-partial-info-plist "$ICON_OUT/partial.plist"+ cp "$ICON_OUT/Assets.car" "$ICON_OUT/AppIcon.icns" "$APP/Contents/Resources/"# The build tools and the Python go into Resources before the bundle is signed (bundle_tools.sh signs each nested Mach-O file# itself: --deep below does not reach code that sits in Resources).tools/bundle_tools.sh "$APP/Contents/Resources" "$RUNNER_TEMP/bundle-tools-work"@@ -120,6 +126,7 @@ jobs:<dict><key>CFBundleExecutable</key><string>NSPortBuilder</string><key>CFBundleIconFile</key><string>AppIcon</string>+ <key>CFBundleIconName</key><string>AppIcon</string><key>CFBundleIdentifier</key><string>org.nxnative.NSPortBuilder</string><key>CFBundleName</key><string>NX2Apple</string><key>CFBundleDisplayName</key><string>NX2Apple</string>diff --git a/frontend/AppIcon.icns b/frontend/AppIcon.icnsdeleted file mode 100644index 627f576b..00000000Binary files a/frontend/AppIcon.icns and /dev/null differdiff --git a/frontend/AppIcon.icon/Assets/bar.svg b/frontend/AppIcon.icon/Assets/bar.svgnew file mode 100644index 00000000..22f65858--- /dev/null+++ b/frontend/AppIcon.icon/Assets/bar.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">+ <path fill="#FFF0D6" fill-rule="nonzero" d="M612.57 696.58L612.57 696.58C612.57 687.66 605.33 680.43 596.41 680.43L427.59 680.43C418.67 680.43 411.43 687.66 411.43 696.58L411.43 696.58C411.43 705.51 418.67 712.74 427.59 712.74L596.41 712.74C605.33 712.74 612.57 705.51 612.57 696.58Z"/>+</svg>diff --git a/frontend/AppIcon.icon/Assets/glow-soft.svg b/frontend/AppIcon.icon/Assets/glow-soft.svgnew file mode 100644index 00000000..b41c0352--- /dev/null+++ b/frontend/AppIcon.icon/Assets/glow-soft.svg@@ -0,0 +1,9 @@+<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">+ <defs><radialGradient id="g" cx="512" cy="440" r="470" gradientUnits="userSpaceOnUse">+ <stop offset="0" stop-color="#FFA54A" stop-opacity="0.95"/>+ <stop offset="0.35" stop-color="#B8561A" stop-opacity="0.7"/>+ <stop offset="0.75" stop-color="#4A1C06" stop-opacity="0.25"/>+ <stop offset="1" stop-color="#1A0A02" stop-opacity="0"/>+ </radialGradient></defs>+ <rect width="1024" height="1024" fill="url(#g)"/>+</svg>diff --git a/frontend/AppIcon.icon/Assets/nx.svg b/frontend/AppIcon.icon/Assets/nx.svgnew file mode 100644index 00000000..68635b09--- /dev/null+++ b/frontend/AppIcon.icon/Assets/nx.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">+ <path fill="#FFF0D6" fill-rule="nonzero" d="M216.21 608.35L216.21 302.62L299.49 302.62L299.49 352.96L301.20 352.96Q313.04 326.58 336.42 311.46Q359.81 296.35 394.46 296.35Q444.80 296.35 472.32 326.79Q499.84 357.24 499.84 411.00L499.84 608.35L416.56 608.35L416.56 428.25Q416.56 398.31 402.52 381.84Q388.47 365.37 360.38 365.37Q341.84 365.37 328.15 373.85Q314.46 382.33 306.98 397.45Q299.49 412.56 299.49 432.67L299.49 608.35ZM511.75 608.35L607.58 456.06L512.47 302.62L606.30 302.62L661.20 406.01L662.91 406.01L717.24 302.62L807.79 302.62L712.25 453.92L807.07 608.35L716.52 608.35L658.49 502.40L656.78 502.40L599.31 608.35Z"/>+</svg>diff --git a/frontend/AppIcon.icon/icon.json b/frontend/AppIcon.icon/icon.jsonnew file mode 100644index 00000000..9f8b6b09--- /dev/null+++ b/frontend/AppIcon.icon/icon.json@@ -0,0 +1,175 @@+{+ "features" : [+ "refractivity"+ ],+ "fill-specializations" : [+ {+ "value" : {+ "linear-gradient" : [+ "srgb:0.11500,0.11500,0.11500,1.00000",+ "srgb:0.03000,0.03000,0.03000,1.00000"+ ]+ }+ },+ {+ "appearance" : "dark",+ "value" : {+ "linear-gradient" : [+ "srgb:0.07000,0.07000,0.07000,1.00000",+ "srgb:0.00000,0.00000,0.00000,1.00000"+ ]+ }+ }+ ],+ "groups" : [+ {+ "layers" : [+ {+ "fill-specializations" : [+ {+ "value" : {+ "linear-gradient" : [+ "srgb:1.00000,0.94000,0.84000,0.85000",+ "srgb:1.00000,0.80000,0.56000,0.80000"+ ]+ }+ },+ {+ "appearance" : "tinted",+ "value" : {+ "solid" : "extended-gray:1.00000,1.00000"+ }+ }+ ],+ "glass" : true,+ "image-name" : "nx.svg",+ "name" : "nx"+ }+ ],+ "lighting" : "individual",+ "name" : "nx",+ "position" : {+ "scale" : 1,+ "translation-in-points" : [+ 0,+ -8+ ]+ },+ "refractivity" : {+ "depth" : 0.6,+ "enabled" : true,+ "strength" : 0.6+ },+ "shadow" : {+ "kind" : "neutral",+ "opacity" : 0.6+ },+ "specular" : true,+ "translucency" : {+ "enabled" : true,+ "value" : 0.5+ }+ },+ {+ "layers" : [+ {+ "fill-specializations" : [+ {+ "value" : {+ "solid" : "srgb:1.00000,0.94000,0.84000,0.90000"+ }+ },+ {+ "appearance" : "tinted",+ "value" : {+ "solid" : "extended-gray:1.00000,0.80000"+ }+ }+ ],+ "glass" : true,+ "hidden" : false,+ "image-name" : "bar.svg",+ "name" : "bar"+ }+ ],+ "lighting" : "individual",+ "name" : "bar",+ "position" : {+ "scale" : 1,+ "translation-in-points" : [+ 0,+ 14+ ]+ },+ "refractivity" : {+ "depth" : 0.6,+ "enabled" : true,+ "strength" : 0.6+ },+ "shadow" : {+ "kind" : "neutral",+ "opacity" : 0.6+ },+ "specular" : true,+ "translucency" : {+ "enabled" : true,+ "value" : 0.4+ }+ },+ {+ "layers" : [+ {+ "glass" : false,+ "hidden" : false,+ "image-name" : "glow-soft.svg",+ "name" : "glow",+ "opacity-specializations" : [+ {+ "value" : 1+ },+ {+ "appearance" : "dark",+ "value" : 0.75+ },+ {+ "appearance" : "tinted",+ "value" : 0+ }+ ]+ }+ ],+ "lighting" : "combined",+ "name" : "glow",+ "shadow" : {+ "kind" : "none",+ "opacity" : 0+ },+ "specular" : false,+ "translucency" : {+ "enabled" : false,+ "value" : 0+ }+ },+ {+ "layers" : [++ ],+ "lighting" : "combined",+ "name" : "glow",+ "shadow" : {+ "kind" : "none",+ "opacity" : 0+ },+ "specular" : false,+ "translucency" : {+ "enabled" : false,+ "value" : 0+ }+ }+ ],+ "supported-platforms" : {+ "squares" : [+ "iOS"+ ]+ }+}\ No newline at end of filediff --git a/frontend/README.md b/frontend/README.mdindex 34a936eb..675ef3e1 100644--- a/frontend/README.md+++ b/frontend/README.md@@ -216,8 +216,14 @@ Paths and the build log use the system's monospaced face. `python3 fonts/embed_fwrites the font into the binary as `Sources/NSPortBuilder/EmbeddedFonts.swift`, so the app needs no fontinstalled and no resource bundle beside the executable.-The app icon is drawn by `make_icon.swift`, and `./make_icon.sh` writes `icon.iconset/`-and `AppIcon.icns` from it.+The app icon is `AppIcon.icon`, the Liquid Glass icon made in Icon Composer (the iOS app uses the same file).+`build-mac-app.yml` compiles it with `actool` into `Assets.car` (macOS 26 and later) and `AppIcon.icns` (macOS 13 to 25),+and `Info.plist` names both. To compile it by hand:++```sh+xcrun actool AppIcon.icon --compile out --platform macosx --minimum-deployment-target 13.0 \+ --app-icon AppIcon --output-partial-info-plist out/partial.plist+```## App updatesdiff --git a/frontend/icon.iconset/icon_128x128.png b/frontend/icon.iconset/icon_128x128.pngdeleted file mode 100644index 843fc086..00000000Binary files a/frontend/icon.iconset/icon_128x128.png and /dev/null differdiff --git a/frontend/icon.iconset/[email protected] b/frontend/icon.iconset/[email protected]deleted file mode 100644index a6fa7499..00000000Binary files a/frontend/icon.iconset/[email protected] and /dev/null differdiff --git a/frontend/icon.iconset/icon_16x16.png b/frontend/icon.iconset/icon_16x16.pngdeleted file mode 100644index 7617a68a..00000000Binary files a/frontend/icon.iconset/icon_16x16.png and /dev/null differdiff --git a/frontend/icon.iconset/[email protected] b/frontend/icon.iconset/[email protected]deleted file mode 100644index 128b77d1..00000000Binary files a/frontend/icon.iconset/[email protected] and /dev/null differdiff --git a/frontend/icon.iconset/icon_256x256.png b/frontend/icon.iconset/icon_256x256.pngdeleted file mode 100644index a6fa7499..00000000Binary files a/frontend/icon.iconset/icon_256x256.png and /dev/null differdiff --git a/frontend/icon.iconset/[email protected] b/frontend/icon.iconset/[email protected]deleted file mode 100644index b575854e..00000000Binary files a/frontend/icon.iconset/[email protected] and /dev/null differdiff --git a/frontend/icon.iconset/icon_32x32.png b/frontend/icon.iconset/icon_32x32.pngdeleted file mode 100644index 128b77d1..00000000Binary files a/frontend/icon.iconset/icon_32x32.png and /dev/null differdiff --git a/frontend/icon.iconset/[email protected] b/frontend/icon.iconset/[email protected]deleted file mode 100644index 5ee6c6e3..00000000Binary files a/frontend/icon.iconset/[email protected] and /dev/null differdiff --git a/frontend/icon.iconset/icon_512x512.png b/frontend/icon.iconset/icon_512x512.pngdeleted file mode 100644index b575854e..00000000Binary files a/frontend/icon.iconset/icon_512x512.png and /dev/null differdiff --git a/frontend/icon.iconset/[email protected] b/frontend/icon.iconset/[email protected]deleted file mode 100644index 3fddbe49..00000000Binary files a/frontend/icon.iconset/[email protected] and /dev/null differdiff --git a/frontend/icon.iconset/icon_64x64.png b/frontend/icon.iconset/icon_64x64.pngdeleted file mode 100644index 5ee6c6e3..00000000Binary files a/frontend/icon.iconset/icon_64x64.png and /dev/null differdiff --git a/frontend/icon.iconset/[email protected] b/frontend/icon.iconset/[email protected]deleted file mode 100644index 843fc086..00000000Binary files a/frontend/icon.iconset/[email protected] and /dev/null differdiff --git a/frontend/make_icon.sh b/frontend/make_icon.shdeleted file mode 100755index ace79ee5..00000000--- a/frontend/make_icon.sh+++ /dev/null@@ -1,14 +0,0 @@-#!/bin/sh-# The app icon from make_icon.swift: icon.iconset/ (every size macOS asks for) and AppIcon.icns, in this folder.-# Usage: frontend/make_icon.sh (then copy AppIcon.icns into NS Port Builder.app/Contents/Resources/)-set -e-cd "$(dirname "$0")"-tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT-swift make_icon.swift "$tmp/master.png"-mkdir -p icon.iconset-for s in 16 32 64 128 256 512; do- sips -z $s $s "$tmp/master.png" --out "icon.iconset/icon_${s}x${s}.png" >/dev/null- sips -z $((s * 2)) $((s * 2)) "$tmp/master.png" --out "icon.iconset/icon_${s}x${s}@2x.png" >/dev/null-done-iconutil -c icns icon.iconset -o AppIcon.icns-echo "AppIcon.icns"diff --git a/frontend/make_icon.swift b/frontend/make_icon.swiftdeleted file mode 100644index 04fd7746..00000000--- a/frontend/make_icon.swift+++ /dev/null@@ -1,77 +0,0 @@-// The app icon: "nx" in the wordmark's face (SF Pro Bold, tight) and the launcher's cream on black, with the-// selection bar the collection uses under it. Renders a 1024 px master on the macOS icon grid.-// Usage: swift frontend/make_icon.swift <out.png> (frontend/make_icon.sh makes AppIcon.icns from it)-import AppKit--let size: CGFloat = 1024-let cream = NSColor(red: 1, green: 0.94, blue: 0.84, alpha: 1)-let amber = NSColor(red: 1, green: 0.80, blue: 0.56, alpha: 1)--let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: Int(size), pixelsHigh: Int(size), bitsPerSample: 8, samplesPerPixel: 4,- hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0)!-NSGraphicsContext.saveGraphicsState()-NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)-let cg = NSGraphicsContext.current!.cgContext--// The tile: 824 px on the 1024 grid, with the system's soft drop shadow-let tile = NSRect(x: 100, y: 100, width: 824, height: 824)-let shape = NSBezierPath(roundedRect: tile, xRadius: 185, yRadius: 185)-cg.saveGState()-cg.setShadow(offset: CGSize(width: 0, height: -12), blur: 28, color: NSColor.black.withAlphaComponent(0.45).cgColor)-NSColor.black.setFill(); shape.fill()-cg.restoreGState()--cg.saveGState()-shape.addClip()-NSGradient(starting: NSColor(white: 0.115, alpha: 1), ending: NSColor(white: 0.03, alpha: 1))!.draw(in: tile, angle: -90)-// A warm glow behind the letters-let glow = NSGradient(colors: [amber.withAlphaComponent(0.15), amber.withAlphaComponent(0.04), .clear], atLocations: [0, 0.55, 1], colorSpace: .deviceRGB)!-glow.draw(fromCenter: NSPoint(x: 512, y: 470), radius: 0, toCenter: NSPoint(x: 512, y: 470), radius: 470, options: [])--// "nx": its outline, centred on its own glyph bounds, filled with a cream-to-amber gradient-let font = NSFont.systemFont(ofSize: 470, weight: .bold)-let text = NSAttributedString(string: "nx", attributes: [.font: font, .kern: -16])-let line = CTLineCreateWithAttributedString(text)-let glyphs = CGMutablePath()-for run in CTLineGetGlyphRuns(line) as! [CTRun] {- let count = CTRunGetGlyphCount(run)- var ids = [CGGlyph](repeating: 0, count: count), positions = [CGPoint](repeating: .zero, count: count)- CTRunGetGlyphs(run, CFRange(location: 0, length: count), &ids)- CTRunGetPositions(run, CFRange(location: 0, length: count), &positions)- let runFont = (CTRunGetAttributes(run) as Dictionary)[kCTFontAttributeName] as! CTFont- for (glyph, position) in zip(ids, positions) {- if let path = CTFontCreatePathForGlyph(runFont, glyph, nil) {- glyphs.addPath(path, transform: CGAffineTransform(translationX: position.x, y: position.y))- }- }-}-let box = glyphs.boundingBoxOfPath-let barGap: CGFloat = 58, barHeight: CGFloat = 26-let block = box.height + barGap + barHeight // letters and bar, centred together-let origin = CGPoint(x: 512 - box.midX, y: 512 - block / 2 + barGap + barHeight - box.minY + 6)-var place = CGAffineTransform(translationX: origin.x, y: origin.y)-let placed = glyphs.copy(using: &place)!-cg.saveGState()-cg.setShadow(offset: CGSize(width: 0, height: -6), blur: 26, color: amber.withAlphaComponent(0.2).cgColor)-cg.addPath(placed); cg.setFillColor(cream.cgColor); cg.fillPath()-cg.restoreGState()-cg.saveGState()-cg.addPath(placed); cg.clip()-NSGradient(starting: cream, ending: amber)!.draw(in: placed.boundingBoxOfPath, angle: -90)-cg.restoreGState()--// The selection bar under the letters-let barWidth = box.width * 0.34-let bar = NSRect(x: 512 - barWidth / 2, y: origin.y + box.minY - barGap - barHeight, width: barWidth, height: barHeight)-cream.setFill(); NSBezierPath(roundedRect: bar, xRadius: barHeight / 2, yRadius: barHeight / 2).fill()--// A hairline on the tile's edge, brighter at the top-cg.restoreGState()-let rim = CGPath(roundedRect: tile.insetBy(dx: 1.5, dy: 1.5), cornerWidth: 183.5, cornerHeight: 183.5, transform: nil)-cg.saveGState()-cg.addPath(rim); cg.setLineWidth(3); cg.replacePathWithStrokedPath(); cg.clip()-NSGradient(starting: NSColor.white.withAlphaComponent(0.22), ending: NSColor.white.withAlphaComponent(0.03))!.draw(in: tile, angle: -90)-cg.restoreGState()--NSGraphicsContext.restoreGraphicsState()-try! rep.representation(using: .png, properties: [:])!.write(to: URL(fileURLWithPath: CommandLine.arguments[1]))diff --git a/frontend/screenshots/gen_hero.py b/frontend/screenshots/gen_hero.pyindex f1df6cc6..5a9a07ff 100644--- a/frontend/screenshots/gen_hero.py+++ b/frontend/screenshots/gen_hero.py@@ -125,11 +125,20 @@ def render(page: str, out: Path, w: int, h: int) -> None:print('saved', out.relative_to(REPO))+def app_icon() -> Path:+ """The 256 px icon from the compiled frontend/AppIcon.icon (actool needs Xcode 26 or later)."""+ out = Path(tempfile.mkdtemp())+ subprocess.run(['xcrun', 'actool', str(REPO / 'frontend/AppIcon.icon'), '--compile', str(out), '--platform', 'macosx',+ '--minimum-deployment-target', '13.0', '--app-icon', 'AppIcon',+ '--output-partial-info-plist', str(out / 'partial.plist')], check=True, stdout=subprocess.DEVNULL)+ subprocess.run(['iconutil', '-c', 'iconset', str(out / 'AppIcon.icns'), '-o', str(out / 'icon.iconset')], check=True)+ return out / 'icon.iconset/[email protected]'++def main() -> int:if not Path(CHROME).exists():sys.exit('needs Google Chrome in /Applications (it renders the HTML)')- common = {'font': (REPO / 'frontend/fonts/Manrope.ttf').as_uri(),- 'icon': (REPO / 'frontend/icon.iconset/[email protected]').as_uri()}+ common = {'font': (REPO / 'frontend/fonts/Manrope.ttf').as_uri(), 'icon': app_icon().as_uri()}games, verified = repo_numbers()w, h = 1050, 350 # 2100x700 at 2x, the banner's old sizefor lang in TEXT.values():diff --git a/frontend/tools/check_bundle.sh b/frontend/tools/check_bundle.shindex 7d4dd85c..e5d735ba 100755--- a/frontend/tools/check_bundle.sh+++ b/frontend/tools/check_bundle.sh@@ -36,6 +36,15 @@ while IFS= read -r -d '' f; dodone < <(find "$RES/tools" "$RES/python" -type f -print0)[ "$links" = 0 ] && ok "no Mach-O file links outside the system or the bundle, and none needs macOS later than 13.0"+# the icon: Assets.car (macOS 26 and later) and AppIcon.icns (13 to 25), and the two Info.plist keys that point at them+if [ -d "$APP/Contents" ]; then+ for f in Assets.car AppIcon.icns; do [ -s "$RES/$f" ] && ok "$f is in the bundle" || bad "$f is missing from Resources"; done+ for k in CFBundleIconName CFBundleIconFile; do+ v=$(/usr/libexec/PlistBuddy -c "Print :$k" "$APP/Contents/Info.plist" 2>&1)+ [ "$v" = AppIcon ] && ok "Info.plist $k = $v" || bad "Info.plist $k is '$v', not AppIcon"+ done+fi+if [ "${2:-}" = "--sign" ] && [ -d "$APP/Contents" ]; thencodesign --force --deep --sign - "$APP" 2>&1 | tail -3codesign -v --deep --strict "$APP" 2>&1 && ok "codesign -v --deep --strict" || bad "codesign -v --deep --strict"