diff --git a/docs/hello-platform.md b/docs/hello-platform.md index 066f33a..fc88754 100644 --- a/docs/hello-platform.md +++ b/docs/hello-platform.md @@ -241,3 +241,18 @@ util/run-windows The build uses the existing generated Swift dialect, like the Linux build. The run script locates the existing debug executable without rebuilding it. + +### Windows executable icon + +`res/AppIcon.res` is a ready-made Windows resource containing six icon sizes +(16–256px) from the shared `res/AppIcon.png`, with icon group ID 101. +`ver-windows/res/AppIcon.res` links to it. No ICO or RC file is required by the +Windows target, and the build does not compile resources. + +`step/buildWindows` exports `APP_RES_DIR` as the absolute Git Bash +`ver-windows/res` path derived from `$SDIR/../ver-windows/res`. +The entry script obtains `SDIR` with `pwd -P`; +no resource copy is needed. The manifest appends `/AppIcon.res` and passes it to the linker. +Manual SwiftPM commands that evaluate the manifest also need `APP_RES_DIR`. +Windows compilation and the live window/taskbar icon require verification on +Windows; no Windows build was performed when this wiring was added. diff --git a/hello/hello-platform/util/step/buildWindows b/hello/hello-platform/util/step/buildWindows index 4ea24f4..7d53de1 100644 --- a/hello/hello-platform/util/step/buildWindows +++ b/hello/hello-platform/util/step/buildWindows @@ -5,4 +5,5 @@ STEP=$((STEP+1)) echo -e "\n> > > > Step №$STEP. Build '$TARGET' for Windows" cd "$SDIR/../ver-windows" +export APP_RES_DIR="$SDIR/../ver-windows/res" swift build diff --git a/hello/hello-platform/ver-windows/Package.swift b/hello/hello-platform/ver-windows/Package.swift index f03156c..bd40a24 100644 --- a/hello/hello-platform/ver-windows/Package.swift +++ b/hello/hello-platform/ver-windows/Package.swift @@ -1,6 +1,9 @@ // swift-tools-version: 5.10 +import Foundation import PackageDescription +let resDir = ProcessInfo.processInfo.environment["APP_RES_DIR"]! + let package = Package( name: "hello-platform", dependencies: [ @@ -13,7 +16,10 @@ let package = Package( .product(name: "SwiftCrossUI", package: "swift-cross-ui"), .product(name: "WinUIBackend", package: "swift-cross-ui") ], - path: "src" + path: "src", + linkerSettings: [ + .unsafeFlags(["-Xlinker", "\(resDir)/AppIcon.res"]) + ] ) ] ) diff --git a/hello/hello-platform/ver-windows/res/AppIcon.res b/hello/hello-platform/ver-windows/res/AppIcon.res new file mode 120000 index 0000000..285de39 --- /dev/null +++ b/hello/hello-platform/ver-windows/res/AppIcon.res @@ -0,0 +1 @@ +../../../../res/AppIcon.res \ No newline at end of file diff --git a/res/AppIcon.res b/res/AppIcon.res new file mode 100644 index 0000000..600493a Binary files /dev/null and b/res/AppIcon.res differ