Build Adwaita for Swift on Windows #26
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: aparoksha/adwaita-swift#26
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the bug
I tried using the library on Windows. I installed GTK and libadwaita using gvsbuild, but when I run
swift run
in PowerShell, the following warning is shown:However, when running pkg-config manually in PowerShell, it finds libadwaita without problems:
To Reproduce
swift run
in PowerShellExpected behavior
I expect the library to compile without problems.
Additional context
No response
Thanks for opening this issue! I haven't tried gvsbuild so far, but I will definitely at some point, so unfortunately, I can't help (I use it on Linux and libadwaita also works best on Linux).
Based on the information you provided, I'd also expect the library to compile.
I'm a bit irritated by the first code snippet saying
png-config
instead ofpkg-config
. Do you know whatpng-config
is, or where there might be a mistake?Thank you for your reply!
I'm sorry! This was a typo by me. I edited the issue to correct the mistake.
@s-k I advanced a little further than you. Maybe you are missing the path to the .pc files?
I downloaded the GTK4 binaries from here: https://github.com/wingtk/gvsbuild/actions/runs/8882441878 and extracted the archive into the C:\GTK4 (I was too lazy do build it from source):
I set the following powershell variables (I used Developer Powershell for VS 2022 by the way):
I basically copy-pasted the ones from https://github.com/wingtk/gvsbuild and added the path to the .pc files (C:\gtk4\lib\pkgconfig in my case). That made the pkg-config issues go away for me.
Now when I try to compile the AdwaitaTemplate project I get these errors:
When I installed swift, visual studio and the windows 11 sdk, I used these commands as described on swift.org:
I think I need to add some additional Visual Studio components but I can't figure out which yet. I tried adding the Universal CRT SDK and the universal windows runtime, but those broke swift.
@alexmocanu Thank you for chiming in. I am not sure that you advanced further than me. To me, it seems that Swift cannot even compile your Package.swift.
@david-swift I made a little progress myself. I had to include all include directories manually:
Now, swift build finds all headers. However, I get an new error:
Yes, I recently installed Windows next to Linux and I got the same error. It appears with Swift packages in general. I skipped the Visual Studio step in the installation process, hoping to be able to use Swift without having to install all that stuff, but that could maybe cause this.
Edit: I just saw you, @s-k, followed the exact instructions 🤔
Thanks for sharing! This doesn't look that beautiful, but it's better than nothing. It looks like you got pretty far!
What's the version of your Libadwaita installation? Version 1.5 is required.
@s-k You're right, I must have messed up something so I started from scratch.
About that missing function error:
I noticed that wingtk seems to be patching out adw_about_window_new_from_appdata from /src/adw-about-window.c. Something about removing AppStream dependency
f5d04f9133/gvsbuild/patches/libadwaita/0001-remove-appstream-dependency.patch (L507)
I think this patch is responsible for that last error.
To test things out I started with an empty swift package having only Adwaita-Swift as dependency.
I removed the reference to that function from GTUIAboutWindow.swift (I left only pointer = adw_about_window_new()?.cast() in there). The swift package seems to compile (with a lot of warnings) but then the linker stops with these errors:
I added "-Xlinker -LC:\gtk4\lib" (that's the path to the .lib files on my machine) and now I'm getting more linker errors:
If it's of any help, I got the Adwaita-Template project to compile and run under Windows:
I had to remove all references to the Localized package in Package.swift and the code itself. It was throwing some compilation errors that were getting in the way.
I had to link every lib file separately (maybe there is a better way? I don't know much about these things)
If you get errors about missing adwaita, gtk, etc. dll files, you have to set the path to them like this (replace C:\gtk with your path):
If you get errors about permissions (like this: :0: error: failed writing record...), make sure to unset the read only attribute from the project's folder (and contents).
@alexmocanu Thank you so much! That did the trick!
I fixed the Adwaita problem in
e9094b9247
so one can now run the template following @alexmocanu's detailed instructions without having to edit the Adwaita package (unfortunately including removing the Localized references, but I'll work on that), using the main branch of Adwaita until the next release.Wow! Great job!
Thank you all for making Swift Adwaita on Windows a reality.