stackotter / swift-cross-ui

A cross-platform declarative UI framework, inspired by SwiftUI.
https://stackotter.github.io/swift-cross-ui/documentation/swiftcrossui/
MIT License
651 stars 36 forks source link

Is there walk-through for building a basic example? #94

Closed g40 closed 2 months ago

g40 commented 2 months ago

Interesting project, thanks.

I've got Swift 6 for Windows installed, and this repo cloned. What are the steps then to build a working executable from the command line (or is VS Code preferred)?

I can also build gtk4 from source with VS2022 to simplify nuget oddities.

stackotter commented 2 months ago

I'll include an answer to this here for future reference (we ended up discussing on Discord instead of GitHub issues).

The examples are in the Examples directory. Here's how you run the CounterExample. Other examples can be run similarly;

cd Examples
swift run CounterExample

If you are on the main branch you can use SCUI_BACKEND=WinUIBackend swift run CounterExample to use a different backend of your choice (in this case WinUIBackend), and if you're on the layout_system branch it's almost the same but the environment variable is now called SCUI_DEFAULT_BACKEND instead.

g40 commented 2 months ago

@stackotter I hate to be a pain but I think it needs more than this. There are an awful lot of moving parts! Once I suss it out, happy to send a PR

g40 commented 2 months ago

BTW as an example of above, another build issue. This is a Windows 10 machine, with Swift 6.0.1 installed just now.

This is a Swift issue. Have raised it in the Swift repo.

r:\src\swift\swift-cross-ui\Examples>swift run CounterExample
error: 'examples': Invalid manifest (compiled with: ["R:\\dev\\swift\\Toolchains\\6.0.1+Asserts\\usr\\bin\\swiftc.exe", "-vfsoverlay", "C:\\Users\\moi\\AppData\\Local\\Temp\\TemporaryDirectory.MqNj9z\\vfs.yaml", "-L", "R:\\dev\\swift\\Toolchains\\6.0.1+Asserts\\usr\\lib\\swift\\pm\\ManifestAPI", "-lPackageDescription", "-sdk", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\SDKs\\Windows.sdk\\", "-libc", "MD", "-I", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows", "-I", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\x86_64", "-L", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\x86_64", "-I", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\Testing-development\\usr\\lib\\swift\\windows", "-L", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\Testing-development\\usr\\lib\\swift\\windows\\x86_64", "-use-ld=lld", "-swift-version", "5", "-I", "R:\\dev\\swift\\Toolchains\\6.0.1+Asserts\\usr\\lib\\swift\\pm\\ManifestAPI", "-package-description-version", "5.9.0", "R:\\src\\swift\\swift-cross-ui\\Examples\\Package.swift", "-o", "C:\\Users\\moi\\AppData\\Local\\Temp\\TemporaryDirectory.q3cJD6\\examples-manifest.exe"])
<unknown>:0: error: could not find module '_Concurrency' for target 'x86_64-unknown-windows-msvc'; found: aarch64-unknown-windows-msvc, i686-unknown-windows-msvc, at: R:\dev\swift\Platforms\6.0.1\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\windows\_Concurrency.swiftmodule
error: 'examples': Invalid manifest (compiled with: ["R:\\dev\\swift\\Toolchains\\6.0.1+Asserts\\usr\\bin\\swiftc.exe", "-vfsoverlay", "C:\\Users\\moi\\AppData\\Local\\Temp\\TemporaryDirectory.sfuMlf\\vfs.yaml", "-L", "R:\\dev\\swift\\Toolchains\\6.0.1+Asserts\\usr\\lib\\swift\\pm\\ManifestAPI", "-lPackageDescription", "-sdk", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\SDKs\\Windows.sdk\\", "-libc", "MD", "-I", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows", "-I", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\x86_64", "-L", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\XCTest-development\\usr\\lib\\swift\\windows\\x86_64", "-I", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\Testing-development\\usr\\lib\\swift\\windows", "-L", "R:\\dev\\swift\\Platforms\\6.0.1\\Windows.platform\\Developer\\Library\\Testing-development\\usr\\lib\\swift\\windows\\x86_64", "-use-ld=lld", "-swift-version", "5", "-I", "R:\\dev\\swift\\Toolchains\\6.0.1+Asserts\\usr\\lib\\swift\\pm\\ManifestAPI", "-package-description-version", "5.9.0", "R:\\src\\swift\\swift-cross-ui\\Examples\\Package.swift", "-o", "C:\\Users\\moi\\AppData\\Local\\Temp\\TemporaryDirectory.CMxAfn\\examples-manifest.exe"])
<unknown>:0: error: could not find module '_Concurrency' for target 'x86_64-unknown-windows-msvc'; found: aarch64-unknown-windows-msvc, i686-unknown-windows-msvc, at: R:\dev\swift\Platforms\6.0.1\Windows.platform\Developer\SDKs\Windows.sdk\usr\lib\swift\windows\_Concurrency.swiftmodule
stackotter commented 2 months ago

@stackotter I hate to be a pain but I think it needs more than this. There are an awful lot of moving parts! Once I suss it out, happy to send a PR

Yeah I do acknowledge that Windows makes the 'once the dependencies have been installed' part quite difficult, if you think it'd be a good idea to have a comprehensive walkthrough of setting up a SwiftCrossUI development environment on Windows (I do) then I'd be happy to look into making one. I think that should be a separate issue specific to Windows cause on Linux and macOS it's pretty simple to run the examples, you can just use homebrew or apt to install Gtk/Qt/whatever and it seems to work out of the box basically every time.

g40 commented 2 months ago

@stackotter 100% agree. Windows is a fickle beast and does deserve special treatment. Once the Swift guys help me resolve the newest problem I'll write up something. BTW do you have a working Windows build machine? Virtual or otherwise?

stackotter commented 2 months ago

Yeah I have a physical Windows machine that could build both the GtkBackend and WinUIBackend successfully last time I used it.