Live data from Hacker News

Ask HN: I want to make a native UI for macOS. What do I use?

news.ycombinator.com

1–9 of 9 posts

Re: Ask HN: I want to make a native UI for macOS. What do I use?

#3
In my native Mac Swift projects typically just generate all the UIKit elements in code and lay them out using NSLayoutConstraints. Once you get a feel for it it is really simple and scales well to different screen dimensions.

I gave up using Storyboards a long time ago.

Re: Ask HN: I want to make a native UI for macOS. What do I use?

#5
post #4

You can use cocoa from swift without a problem. That would be what I would be inclined to use.

Yup, here's a great resource for learning AppKit and Cocoa: https://www.youtube.com/c/AppleProgramming. The creator of these videos used to be on the Photos team at Apple.

Re: Ask HN: I want to make a native UI for macOS. What do I use?

#6
From a UX standpoint, Swift & AppKit is the only “proper” way to make a native UI for macOS at this current time.

SwiftUI is a mobile focused framework still being adapted to macOS, I think it’s just gotten tables this year? And even the best Catalyst app in the world (craft.do) will sit somewhere in between Electron and uncanny valley at times when it comes to things as simple as a button.

I would highly recommend using AppKit if the app is even slightly nontrivial and fit and finish is a goal.

If it’s a simple app and you’re ok with visual hitches and oddities but would like a native macOS “skin”, SwiftUI.

If fit and finish isn’t important, just use Electron.

Re: Ask HN: I want to make a native UI for macOS. What do I use?

#7

From a UX standpoint, Swift & AppKit is the only “proper” way to make a native UI for macOS at this current time. SwiftUI is a mobile focused framework still being adapted to macOS, I think it’s just gotten tables this year? And even the best Catalyst app in the world (craft.do) will sit somewhere in between Electron and uncanny valley at times when it comes to things as simple as a button. I would highly recommend u…

I'd consider the built-in Messages app to be the best Mac Catalyst app, it doesn't look and feel out of place to me.

Re: Ask HN: I want to make a native UI for macOS. What do I use?

#8

From a UX standpoint, Swift & AppKit is the only “proper” way to make a native UI for macOS at this current time. SwiftUI is a mobile focused framework still being adapted to macOS, I think it’s just gotten tables this year? And even the best Catalyst app in the world (craft.do) will sit somewhere in between Electron and uncanny valley at times when it comes to things as simple as a button. I would highly recommend u…

Your answer is correct. Swift & AppKit is what you should use for a native macOS app today.

Only one thing to add: Embrace the fact that Swift and Objective C are compatible! Some parts are way easier to write in Objective C, eg. anything that interfaces with C code.

Also, if your app does non-trivial amounts of text editing, those parts should probably be written in Objective C.

Working with NSTextView / NSString / NSMutableString / NSAttributedString in Swift is difficult. You always need to be super careful not to mix up Objective C characters (UTF-16) with Swift characters ("Grapheme clusters"). Even as someone who read a lot about those topics it's easy to mix them up. It's also easy to run into catastrophic performance problems, eg. checking large strings for equality is really slow in Swift, and can easily lead to UI hangs.

Re: Ask HN: I want to make a native UI for macOS. What do I use?

#9
It'd help to know what your UI will do.

For most applications, I'd suggest SwiftUI. That's because most UIs are for straightforward CRUD apps. Because everyone else here makes great points. There are lots of reasons to avoid SwiftUI at the moment.

However, I've made a handful of SwiftUI apps for macOS that were more than simple. It works well.