diff --git a/README.md b/README.md index 501b24f..31e0093 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,94 @@ ## Prerequisites -### macOS - -* `brew install raylib` - -### iOS - -* `brew install xcodegen` -* ghera's [raylib-ios-xcframeworks][rzip] release unpacked and placed alongside the project - ### Android -* Android Studio Quail 3 (2026.1.3) +* Install Android Studio Quail 3 (2026.1.3) + +### iOS + +* Install Xcode 26 +* Install XcodeGen + + `brew install xcodegen` +* Get ghera's [raylib-ios-xcframeworks][rzip] + + Unpack and place it alongside the project ### Linux -* Ubuntu 24.04 -* [Swiftly][swiftly] + Swift (installed by Swiftly) -* Swift dependencies (proposed by Swiftly after Swift installation) +* Install Ubuntu 24.04 +* Install [Swiftly][swiftly] + Swift (installed by Swiftly) +* Install Swift dependencies (proposed by Swiftly after Swift installation) + `apt-get -y install binutils git gnupg2 libcurl4-openssl-dev libgcc-13-dev libpython3-dev libstdc++-13-dev libxml2-dev libncurses-dev libz3-dev pkg-config zlib1g-dev` -* CrossSwiftUI dependency +* Install CrossSwiftUI dependency + `apt-get -y install libgtk-4-dev` +### macOS + +* Install Xcode 26 +* Install Raylib 6 + + `brew install raylib` + +### Windows + +![Developer mode][w11-dev-mode] + +* Install Windows 11 + + Use x64 Windows if you want to target both Intel and ARM + +* Install [Visual Studio 2022 and Swift toolchain][vs] +* Install App Runtime + + `winget install --id Microsoft.WindowsAppRuntime.1.5 -e --source winget` + +* Enable developer mode + + Settings -> System -> Advanced -> Developer Mode: On (see the screenshot above) + +* Install Git Bash + + `winget install --id Git.Git -e --source winget` + + While in Git Bash installation wizard, select defaults + +* Inside Git Bash: configure Git to use actual symlinks + + `git config --global core.symlinks true` + +* Inside GitBash: find the location of `swift.exe` + + ``` + $ find /c -name swift.exe + /c/Users/mk/AppData/Local/Programs/Swift/Toolchains/6.4.2+Asserts/usr/bin/swift.exe + ``` + +* Inside Git Bash: to `~/.bash_profile` add Swift location (without `swift.exe`) to `PATH` + + `export PATH="$PATH:/c/Users/mk/AppData/Local/Programs/Swift/Toolchains/6.4.2+Asserts/usr/bin"` + +* Restart Git Bash + +* Make sure Swift compiler is working + + ``` + $ swift --version + Swift version 6.4.2 (swift-6.4.2-RELEASE) + Target: aarch64-unknown-windows-msvc + Build config: +assertions + ``` + ## Components | Component | macOS | iOS | Android | Linux | Windows | Description | | --- | --- | --- | --- | --- | --- | --- | -| hp | √ | √ | √ | ? | | **h**ello-**p**latform is a simple UI to validate platform support | +| hp | √ | √ | √ | √ | √ | **h**ello-**p**latform is a simple UI to validate platform support | +| hrb | | | | | | **h**ello-**r**ayli**b** is a simple raylib rendering to validate platform support | [rzip]: https://github.com/ghera/raylib-iOS/releases/download/6.2.0-iOS/raylib-ios-xcframeworks-6.2.0-iOS.zip [swiftly]: https://www.swift.org/install/linux/ +[vs]: https://www.swift.org/install/windows/ +[w11-dev-mode]: docs/img/w11-dev-mode.jpg diff --git a/components/other/windows/otherWindows.swift b/components/other/windows/otherWindows.swift new file mode 100644 index 0000000..e3b6f85 --- /dev/null +++ b/components/other/windows/otherWindows.swift @@ -0,0 +1,35 @@ +import WinSDK + +func otherSetupWindowIcon(_ iconId: Int) { + // Only visit windows owned by this UI thread, never another application's window + EnumThreadWindows(GetCurrentThreadId(), { wnd, iconId in + let resource = UnsafePointer(bitPattern: Int(iconId)) + let module = GetModuleHandleW(nil) + + // Small icon + if let small = LoadImageW( + module, + resource, + UINT(IMAGE_ICON), + GetSystemMetrics(SM_CXSMICON), + GetSystemMetrics(SM_CYSMICON), + UINT(LR_SHARED) + ) { + SendMessageW(wnd, UINT(WM_SETICON), WPARAM(ICON_SMALL), LPARAM(Int(bitPattern: small))) + } + + // Large icon + if let large = LoadImageW( + module, + resource, + UINT(IMAGE_ICON), + GetSystemMetrics(SM_CXICON), + GetSystemMetrics(SM_CYICON), + UINT(LR_SHARED) + ) { + SendMessageW(wnd, UINT(WM_SETICON), WPARAM(ICON_BIG), LPARAM(Int(bitPattern: large))) + } + + return true + }, LPARAM(iconId)) +} diff --git a/docs/hello-platform.md b/docs/hello-platform.md index 510ca2b..fc88754 100644 --- a/docs/hello-platform.md +++ b/docs/hello-platform.md @@ -223,3 +223,36 @@ it installs the executable, launcher and icon for the current user and refreshes the desktop/icon caches. It requires GNU sed, gtk-update-icon-cache and update-desktop-database. The standalone `install-linux` script has been replaced by this packaging step. + +## Windows (WinUI) + +`ver-windows/` mirrors the Linux SwiftCrossUI target with `WinUIBackend`. +It shares the counter component and generated Swift dialect via +relative symlinks. It reuses the SwiftCrossUI model and view in `components/hp/linux`. Check out the repository with Git symlinks enabled on Windows +(Developer Mode or appropriate symlink permissions are needed). + +With the Windows Swift toolchain, Windows SDK, and the Windows App SDK runtime +required by SwiftCrossUI's WinUI backend installed, run in Git Bash from `hello/hello-platform`: + +```bash +util/build-windows +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/docs/img/w11-dev-mode.jpg b/docs/img/w11-dev-mode.jpg new file mode 100644 index 0000000..4b615d9 Binary files /dev/null and b/docs/img/w11-dev-mode.jpg differ diff --git a/hello/hello-platform/util/build-windows b/hello/hello-platform/util/build-windows new file mode 100755 index 0000000..e7a2826 --- /dev/null +++ b/hello/hello-platform/util/build-windows @@ -0,0 +1,8 @@ +#!/bin/bash -e +SDIR=$(cd "$(dirname "$0")" && pwd -P) + +T=$SDIR/step +TARGET=hello-platform + +STEP=0 +source "$T/buildWindows" "$TARGET" diff --git a/hello/hello-platform/util/run-windows b/hello/hello-platform/util/run-windows new file mode 100755 index 0000000..143dec8 --- /dev/null +++ b/hello/hello-platform/util/run-windows @@ -0,0 +1,8 @@ +#!/bin/bash -e +SDIR=$(cd "$(dirname "$0")" && pwd -P) + +T=$SDIR/step +TARGET=hello-platform + +STEP=0 +source "$T/runWindows" "$TARGET" diff --git a/hello/hello-platform/util/step/buildWindows b/hello/hello-platform/util/step/buildWindows new file mode 100644 index 0000000..7d53de1 --- /dev/null +++ b/hello/hello-platform/util/step/buildWindows @@ -0,0 +1,9 @@ +#!/bin/bash -e + +TARGET=$1 +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/util/step/runWindows b/hello/hello-platform/util/step/runWindows new file mode 100644 index 0000000..dc69fe2 --- /dev/null +++ b/hello/hello-platform/util/step/runWindows @@ -0,0 +1,8 @@ +#!/bin/bash -e + +TARGET=$1 +STEP=$((STEP+1)) +echo -e "\n> > > > Step №$STEP. Run Windows app for '$TARGET'" + +cd "$SDIR/../ver-windows" +"./.build/debug/$TARGET.exe" diff --git a/hello/hello-platform/ver-windows/Package.swift b/hello/hello-platform/ver-windows/Package.swift new file mode 100644 index 0000000..bd40a24 --- /dev/null +++ b/hello/hello-platform/ver-windows/Package.swift @@ -0,0 +1,25 @@ +// swift-tools-version: 5.10 +import Foundation +import PackageDescription + +let resDir = ProcessInfo.processInfo.environment["APP_RES_DIR"]! + +let package = Package( + name: "hello-platform", + dependencies: [ + .package(url: "https://github.com/moreSwift/swift-cross-ui", branch: "v0.10.0") + ], + targets: [ + .executableTarget( + name: "hello-platform", + dependencies: [ + .product(name: "SwiftCrossUI", package: "swift-cross-ui"), + .product(name: "WinUIBackend", package: "swift-cross-ui") + ], + 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/hello/hello-platform/ver-windows/src/HPApp.swift b/hello/hello-platform/ver-windows/src/HPApp.swift new file mode 100644 index 0000000..e634e1d --- /dev/null +++ b/hello/hello-platform/ver-windows/src/HPApp.swift @@ -0,0 +1,16 @@ +import SwiftCrossUI +import WinUIBackend + +@main +struct HPApp: App { + let delegate = HPAppDelegate() + + var body: some Scene { + WindowGroup("Hello platform") { + HPView(delegate.hpVM) + .onAppear { + delegate.setup() + } + } + } +} diff --git a/hello/hello-platform/ver-windows/src/HPAppDelegate.swift b/hello/hello-platform/ver-windows/src/HPAppDelegate.swift new file mode 100644 index 0000000..c2d8d69 --- /dev/null +++ b/hello/hello-platform/ver-windows/src/HPAppDelegate.swift @@ -0,0 +1,11 @@ +final class HPAppDelegate { + let hp = HPComponent() + let hpVM = HPVM() + + func setup() { + otherSetupConsoleLogging(hp.ctrl, "HP") + hp.setup() + otherSetupWindowIcon(101) + } + +} diff --git a/hello/hello-platform/ver-windows/src/dialect.swift b/hello/hello-platform/ver-windows/src/dialect.swift new file mode 120000 index 0000000..a931c95 --- /dev/null +++ b/hello/hello-platform/ver-windows/src/dialect.swift @@ -0,0 +1 @@ +../../ver-mac/src/dialect.swift \ No newline at end of file diff --git a/hello/hello-platform/ver-windows/src/hp/hp.swift b/hello/hello-platform/ver-windows/src/hp/hp.swift new file mode 120000 index 0000000..b83cde2 --- /dev/null +++ b/hello/hello-platform/ver-windows/src/hp/hp.swift @@ -0,0 +1 @@ +../../../../../components/hp/hp.swift \ No newline at end of file diff --git a/hello/hello-platform/ver-windows/src/hp/hpVM.swift b/hello/hello-platform/ver-windows/src/hp/hpVM.swift new file mode 120000 index 0000000..7394425 --- /dev/null +++ b/hello/hello-platform/ver-windows/src/hp/hpVM.swift @@ -0,0 +1 @@ +../../../../../components/hp/linux/hpVM.swift \ No newline at end of file diff --git a/hello/hello-platform/ver-windows/src/hp/view/HPView.swift b/hello/hello-platform/ver-windows/src/hp/view/HPView.swift new file mode 120000 index 0000000..1b79f15 --- /dev/null +++ b/hello/hello-platform/ver-windows/src/hp/view/HPView.swift @@ -0,0 +1 @@ +../../../../../../components/hp/linux/view/HPView.swift \ No newline at end of file diff --git a/hello/hello-platform/ver-windows/src/other/other.swift b/hello/hello-platform/ver-windows/src/other/other.swift new file mode 120000 index 0000000..8c61410 --- /dev/null +++ b/hello/hello-platform/ver-windows/src/other/other.swift @@ -0,0 +1 @@ +../../../../../components/other/other.swift \ No newline at end of file diff --git a/hello/hello-platform/ver-windows/src/other/otherWindows.swift b/hello/hello-platform/ver-windows/src/other/otherWindows.swift new file mode 120000 index 0000000..72dde1b --- /dev/null +++ b/hello/hello-platform/ver-windows/src/other/otherWindows.swift @@ -0,0 +1 @@ +../../../../../components/other/windows/otherWindows.swift \ No newline at end of file diff --git a/history/gitjs/пуск|run.js b/history/gitjs/пуск-run.js similarity index 100% rename from history/gitjs/пуск|run.js rename to history/gitjs/пуск-run.js diff --git a/history/gitjs/пуск|run.череда b/history/gitjs/пуск-run.череда similarity index 100% rename from history/gitjs/пуск|run.череда rename to history/gitjs/пуск-run.череда 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