TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Writing Gnome Apps with Swift

552 点作者 msk-lywenn大约 1 年前

28 条评论

w10-1大约 1 年前
For another SwiftUI-like wrapper, see also <a href="https:&#x2F;&#x2F;github.com&#x2F;stackotter&#x2F;swift-cross-ui">https:&#x2F;&#x2F;github.com&#x2F;stackotter&#x2F;swift-cross-ui</a> (used by Adawaita to generate widgets, and mentioned in other comments).<p>The key premise of this approach is to provide a SwiftUI-like declarative wrapper around Gnome functionality. It&#x27;s unclear what it adds over swift-cross-ui.<p>SwiftUI itself has growing pains mainly around being on the right thread for processing&#x2F;updates and getting data binding right.<p>Blog entries on swift.org or from Apple tend to be little demos that show the happy path, but when discussing new frameworks (like a Gnome wrapper) or platforms (like the recent embedded), I&#x27;d like more demonstration that the authors understand and address key issues and will sustain development. Cross-platform UI frameworks get complicated quickly and have a long tail of issues (cf Flutter, Java&#x2F;Eclipse, et al) that can be blockers for clients&#x2F;users. For Swift it doesn&#x27;t help to have multiple concurrency models and obviously different behaviors on apple platforms and Linux (where UI is not officially tested).
评论 #39847488 未加载
nickwarren大约 1 年前
Swift is such a delightful language to use, well suited for general application development. It&#x27;s awesome to see it gaining traction outside of the cocoa ecosystem. If you haven&#x27;t given it a fair chance yet, I would highly recommend you do!
lukeh大约 1 年前
Other things worth checking:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;stackotter&#x2F;swift-cross-ui">https:&#x2F;&#x2F;github.com&#x2F;stackotter&#x2F;swift-cross-ui</a> <a href="https:&#x2F;&#x2F;github.com&#x2F;TokamakUI&#x2F;Tokamak">https:&#x2F;&#x2F;github.com&#x2F;TokamakUI&#x2F;Tokamak</a><p>I’m also working (slowly) on native Flutter channels:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;PADL&#x2F;FlutterSwift">https:&#x2F;&#x2F;github.com&#x2F;PADL&#x2F;FlutterSwift</a><p>But this is really targeted at embedded use cases.
评论 #39846896 未加载
评论 #39847054 未加载
评论 #39847128 未加载
etaioinshrdlu大约 1 年前
I&#x27;m having Deja Vu from about 20 years ago of writing Gnome apps in C# using Mono.
评论 #39848569 未加载
评论 #39852230 未加载
评论 #39846362 未加载
评论 #39846485 未加载
zengid大约 1 年前
I feel like a cross platform Swift GUI would be a great thing for the world. Swift strikes a great balance between ergonomics and performance, and seems to be the only other mainstream language to have absorbed some of Rust&#x27;s key features around borrowing references.
评论 #39854479 未加载
评论 #39854542 未加载
l72大约 1 年前
I recently wrote a small side project using vala + gtk4.<p>I tried blueprint, and while I liked the format, I struggled with a lack of documentation on how to do some more advanced things. Gtk&#x27;s .ui files are ok, but you still end up writing a lot of code to hook everything up.<p>While I really like vala as a language, I think it&#x27;d be great to write all my logic and models in vala, then use this swift library for the UI.
评论 #39846633 未加载
treprinum大约 1 年前
Writing UI code layouts is suboptimal in any language. Delphi had it right - place whatever controls you like in a GUI, set up basic behavior via properties, then just quickly write handlers in code.
评论 #39850197 未加载
评论 #39849342 未加载
评论 #39848921 未加载
评论 #39849079 未加载
评论 #39849055 未加载
评论 #39849259 未加载
评论 #39849889 未加载
评论 #39851273 未加载
imbnwa大约 1 年前
I’ve recently noticed Swift sneakily becoming an interesting option for desktop dev. On top of this example I’d add Arc for macOS and Windows.
评论 #39850088 未加载
koito17大约 1 年前
Something like SwiftUI but open source and targeting GTK4 would be pretty close to my &quot;dream framework&quot; for cross-platform desktop UI.<p>I will admit, Swift syntax is an acquired taste, but once you&#x27;re familiar with all of the concepts (and understand that some design decisions were made for Objective-C interoperability), then it&#x27;s a very usable language. To be frank, the only thing that stops me from using Swift is the fact that Linux support isn&#x27;t as good as on Apple platforms. But if I am targeting nothing but Apple platforms, then Swift is probably the best choice, just for SwiftUI and SPM alone.
评论 #39846373 未加载
评论 #39845348 未加载
评论 #39845286 未加载
评论 #39846372 未加载
评论 #39845254 未加载
评论 #39845418 未加载
评论 #39848334 未加载
评论 #39845354 未加载
pona-a大约 1 年前
That looks really nice! A healthy balance of reactive UI, expressiveness, and sanity. I wonder if there&#x27;s a similar Swift binding for Qt... Ubuntu Touch and KDE could really benefit from that, as QML proved to be a total typing nightmare from my experience, often even slightly worse than regular JS thanks to its quirks...
YmiYugy大约 1 年前
Has anyone been able to get this running on Mac. Followed the instructions, but I always get a missing adwaita.h in some shim.h
评论 #39847273 未加载
评论 #39847339 未加载
FireInsight大约 1 年前
This is really cool! I love the JSX-like approach to UI and it&#x27;s a shame it&#x27;s not so common on desktop. <a href="https:&#x2F;&#x2F;github.com&#x2F;can-lehmann&#x2F;owlkettle">https:&#x2F;&#x2F;github.com&#x2F;can-lehmann&#x2F;owlkettle</a> is the only thing I find comparable.
评论 #39850219 未加载
nurettin大约 1 年前
You could say &quot;writing Gtk code in X language where I implemented a DSL for this special case is easy!&quot; in any PR piece.<p>You could do it in Python using contextmanager which packs after adding the widget to HBox to save a line, you could do it in Ruby using do&#x2F;end blocks, you could do it in C with the help of some pretty macros.
tschumacher大约 1 年前
I wonder where the pulse is with current GTK app development. I&#x27;ve noticed some of the newer core apps are in Rust like the new camera app and the image viewer, also the public transport app railway (not a core app afaik).
tripdout大约 1 年前
Is this the only declarative way to write desktop app UI? (Maybe Kaitlin multiplatform, but not sure how that works on Linux). I mean GTK&#x2F;Qt
throw_m239339大约 1 年前
So, the elephant in room, what&#x27;s the best way&#x2F;framework today to write desktop apps for linux (no electron)?
评论 #39846363 未加载
评论 #39848996 未加载
评论 #39848484 未加载
评论 #39847528 未加载
jamilbk大约 1 年前
That&#x27;s neat!<p>But how is everyone testing their Swift codebases? We&#x27;ve found the story around testing to be... lacking. The [docs](<a href="https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;xctest" rel="nofollow">https:&#x2F;&#x2F;developer.apple.com&#x2F;documentation&#x2F;xctest</a>) on the subject are pretty bare and don&#x27;t offer strategies for mocks, stubs, reporting, code coverage, etc.<p>And good luck if your app uses a Network Extension... those must be tested on a live physical device due to the signing restrictions!<p>On that note, does anyone know of a good physical device CI service that supports both iOS <i>and</i> macOS devices?
评论 #39846123 未加载
msie大约 1 年前
I always thought that introducing keys in function parameters was a mistake.
评论 #39845907 未加载
评论 #39845720 未加载
评论 #39845654 未加载
评论 #39848037 未加载
accurrent大约 1 年前
How is the 3D story on gtk4 am I still stuck to opengl contexts?
codedokode大约 1 年前
I don&#x27;t understand why there are so many negative comments. Writing GUI in C looks like a stone age programming, and people are simply wasting their time to do routine work that can be diminished by using another language. One might use Python, but it is slow and memory-hungry.<p>Isn&#x27;t it good that now there is an alternative to C?
评论 #39849878 未加载
评论 #39849198 未加载
评论 #39849507 未加载
评论 #39850127 未加载
评论 #39851522 未加载
评论 #39852506 未加载
评论 #39850302 未加载
评论 #39852249 未加载
coldtea大约 1 年前
&gt;<i>The primary motivation for this package is to enable the use of Swift when writing GNOME apps, for all the reasons outlined above</i><p>The only problem I have with such projects is when they are unmaintained, in various stages of immaturity, and have little adoption (vicious circle).<p>You find them, they promise exactly what you need, and then you fell into issue after issue in practical use (*).<p>It would be amazing if there was (perhaps this is or will be) well maintained bindings for Swift&#x2F;Rust&#x2F;Go and co for Gnome.<p>* Yes, it&#x27;s open source and you can fix some of the issues yourself. Doesn&#x27;t mean you have the know-how or time to fix all of them, especially when there are lots of things to fix or features missing. Ideally a big community must exist, so that each can just work on or fix a small part and the problem still get lots of fixes&#x2F;improvements incoming, as opposed to &quot;fully replace the single overworked maintainer yourself&quot;.
评论 #39845377 未加载
评论 #39845498 未加载
评论 #39845398 未加载
评论 #39845400 未加载
vi4m大约 1 年前
Really something we needed.<p>Swift has such low memory usage, that it&#x27;s an order of magnitude easier on resources, than those Electron wrappers. At the same time, it gives what you loved about React - expressiveness for UI.<p><pre><code> I wrote a lot of apps in SwiftUI, and it strikes a good balance between type safety and expressiveness, it&#x27;s cool that we have something similar for GKT&#x2F;Gnome now.</code></pre>
评论 #39852275 未加载
eptcyka大约 1 年前
Is there a language server for Swift that does not suck?<p>I believe swift is a good language, however its ecosystem being steered by apple is a massive red flag. It also suffers a bit from being a commercially developed language in that its developers are clearly incentivized to add more features.
评论 #39846236 未加载
评论 #39845470 未加载
评论 #39847614 未加载
评论 #39846130 未加载
Apocryphon大约 1 年前
Flutter desktop app support has been on Ubuntu since 2021, but not sure if that ever got anywhere.
评论 #39845459 未加载
评论 #39845570 未加载
评论 #39846133 未加载
QuantumG大约 1 年前
The article doesn&#x27;t summarise the differences between developing these cross-platform apps vs only targetting Apple and that is the most important information really.<p>Did I miss it?
评论 #39846235 未加载
worik大约 1 年前
I spent 3-years with Swift recently<p>Makes me want to ask: Why? Why do this?<p>It is a decent language for 2005. But it has some serious shortcomings (reference counting garbage collector? Really?)<p>The worst thing IMO is its dreadful support for threads. The &quot;DispatchQueue&quot; seems to be a wrapper around &quot;fork&#x2F;renice&quot;. There is no attempt at memory protection.<p>But it is full of little niggles that get very irritating in this day and age.<p>I never used Objective-C so it may be a vast improvement on that.<p>It is no longer 2005, and we deserve, and we have, better languages.<p>My time as an Apple developer left me with the overwhelming sensation that Apple hates its developers. So much cool looking stuff that mostly worked...
评论 #39845711 未加载
评论 #39845948 未加载
评论 #39845717 未加载
评论 #39847621 未加载
评论 #39845707 未加载
keyle大约 1 年前
It&#x27;s an interesting value proposition. But can I take my existing SwiftUI app and have a path towards porting them to Linux and windows? How foreign would they look since Apple&#x27;s patterns aren&#x27;t the same.
Obertr大约 1 年前
I had an extremely negative experience creating apps in Swift.<p>I can&#x27;t see any logical reason why people would not use Electron&#x2F;Tauri.<p>Swift doesn&#x27;t allow you to have full control of what you want to do.<p>I built a whole macOS [ fixkey dot ai] app in Swift, and it was a very painful development experience.
评论 #39850599 未加载