I'm just finshing up my first macOS app. I went with SwiftUI because I was new and didn't want to learn an "old" tech. The reality is outside of very basic stuff, SwiftUI is not capable of doing a lot of stuff, so I ended up have to learn not only AppKit as well, but how to fuse AppKit into SwiftUI and fuse SwiftUI into AppKit. My advice is don't be attracted by the shiny toy that is SwiftUI. It's a steaming pile to…
It’s probably more productive to mention what about SwiftUI is a “steaming pile of dung”. For most mobile UI, you can spit out a working design faster than w/ AppKit. It doesn’t even have to be one or the other, you can meld both. What’s the value in talking about SwiftUI being incapable when you don’t mention what you can’t do in it.
Ask HN: Resources to Learn macOS Development?
51–60 of 91 posts
Re: Ask HN: Resources to Learn macOS Development?
#52If you want to go for the typical macOS look & feel stick with AppKit.
Resources: barely any
Apparently you’re either not interested in macOS development or you’re way too experienced to need help.
Re: Ask HN: Resources to Learn macOS Development?
#53"I am looking for explanations that will help me build a conceptual understanding of macos UI development." it depends on your learning style of course, but if you like lecture / course-style learning, i highly recommend paul hegarty's CS193P, it will definitely give you the in-depth, conceptual explanations you're describing. while it is an iOS dev course (taught at stanford, lectures are freely offered online), the…
> while it is an iOS dev course (taught at stanford, lectures are freely offered online), the newest lectures are using swiftUI for UI, so pretty much all of it will translate to doing macOS dev. They absolutely will not. SwiftUI on macOS and SwiftUI on iOS are very different beasts. For the latter, it is at the point where you can actually kind of make a good app in it with the majority of your code only using the f…
How recent was your experience with it? I'm assuming your characterization is accurate, but since SwiftUI is being used for notable bits of Ventura, I'm curious what OS version it reflects. https://troz.net/post/2022/swiftui-mac-2022/
Re: Ask HN: Resources to Learn macOS Development?
#54Do a little iOS dev since that has 100x more learning resources. Once you grok iOS, you'll be at home with macOS since they follow the same patterns. Stick with storyboards, don't bother with SwiftUI (no, really, don't do it) and try to use as much default out of the box behaviour as possible, instead of wondering 'how do I do that X thing I did on platform Y'.
Storyboards are slow compared to Live Preview, and lead beginners to adopt bad patterns like Massive View Controllers rather than composable/testable SwiftUI components. Not to mention its horrendous XML format.
Citation needed. Even on Apple silicon, I'm not even sure Live Preview can crash faster than Interface Builder and it has no shortage of practice.
> lead beginners to adopt bad patterns like Massive View Controllers rather than composable/testable SwiftUI components
There is no requirement at all on how big a storyboard is and allowing things to occupy the same *.storyboard where they would have to separate XIB files is an imporvement where it is useful.
> Not to mention its horrendous XML format
Where it does not come at other costs, standard formats (XML) are easier to operate with external tools over bespoke formats (turing complete Obj-C or Swift code). The properties in those files were more numerous than their SwiftUI counterparts, but they served a purpose.
Working with SwiftUI and the bonanza of implied default behaviors required to achieve its terseness add new salience to the idea "it is better to be explicit than implicit".
Re: Ask HN: Resources to Learn macOS Development?
#55I would suggest Cocoa Programming for Mac OS X , even though it's based on Objective-C and the book is old. That means it's based upon older versions of Xcode and Mac OS (like ~10 years old). Conceptually it's a good book, but because of it's age the code examples, etc are outdated. The publisher does have forums which can be helpful: https://forums.bignerdranch.com/c/cocoa-programming-for-os-x... They also have a Sw…
This is the best answer for hobby Mac programming for AppKit in Objective-C. As others have said, SwiftUI is the future and you might want to instead look at that if you can find a decent guide to it -- a lot of what's on the web is very badly obsolete already. It's a very different model. Folks, there will come a point where new UI features don't ship anymore for AppKit. Telling people not to learn SwiftUI is extrem…
If you want to make Mac apps, learn AppKit. You can use AppKit from Swift just fine, there's no need to use Objective C. Some of the text APIs are a bit cumbersome to use with Swift because of the different string semantics, but for the most part writing AppKit code in Swift is pretty sweet.
Re: Ask HN: Resources to Learn macOS Development?
#56shamelessly off-topic but if anyone here is already good at Objective-C development for macOS and looking for remote work, please drop us a line at: jobs@corecode.io
Re: Ask HN: Resources to Learn macOS Development?
#57I started with one of the Big Nerd Ranch books many years ago. I spent a few evenings reading it, and then spent a few hours dabbling with Objective C in XCode. I then got frustrated and put it down for a few years until I took a job that involved some Objective C. (This was over a decade ago.)
It's surprisingly easy to learn the details of system calls by Googling and looking at stack overflow. Yes, the semantics are different, but the general theory is the same. There's a main thread that's often referred to as the main run loop. Accessing your UI outside of the main run loop (thread) is a big no-no.
As much as I want to vouch for learning Swift, (it's really easy if you have a Java / C# background,) there's also a good reason to be proficient in Objective C: It's just a layer on top of C. It's very easy to wrap C APIs in Objective C and then call them from Swift. This is important, because if you're trying to do something low-level, you will need to interact with a C API. (Although, Swift fixes a lot of the weirdness of Objective C if all you want is something that's like Java / C#.)
FWIW: There are some semantic differences that can take some time to adjust to. In Objective C, sending a message to a null object is a no-op instead of a runtime exception. Swift appears memory safe, but I've done things with timers that cause surprise crashes.
Re: Ask HN: Resources to Learn macOS Development?
#58Re: Ask HN: Resources to Learn macOS Development?
#59I would suggest Cocoa Programming for Mac OS X , even though it's based on Objective-C and the book is old. That means it's based upon older versions of Xcode and Mac OS (like ~10 years old). Conceptually it's a good book, but because of it's age the code examples, etc are outdated. The publisher does have forums which can be helpful: https://forums.bignerdranch.com/c/cocoa-programming-for-os-x... They also have a Sw…
This is the best answer for hobby Mac programming for AppKit in Objective-C. As others have said, SwiftUI is the future and you might want to instead look at that if you can find a decent guide to it -- a lot of what's on the web is very badly obsolete already. It's a very different model. Folks, there will come a point where new UI features don't ship anymore for AppKit. Telling people not to learn SwiftUI is extrem…
Re: Ask HN: Resources to Learn macOS Development?
#60Earlier quoted context omitted.
> while it is an iOS dev course (taught at stanford, lectures are freely offered online), the newest lectures are using swiftUI for UI, so pretty much all of it will translate to doing macOS dev. They absolutely will not. SwiftUI on macOS and SwiftUI on iOS are very different beasts. For the latter, it is at the point where you can actually kind of make a good app in it with the majority of your code only using the f…
> On the other hand making a good macOS app using only SwiftUI is pretty much impossible. How recent was your experience with it? I'm assuming your characterization is accurate, but since SwiftUI is being used for notable bits of Ventura, I'm curious what OS version it reflects. https://troz.net/post/2022/swiftui-mac-2022/
SwiftUI on macOS is currently ok for a few usecases. One is little document apps. Emphasis on little, this is going to be things that wrap an image or a text file or something. The API is reactive so it’s not really designed for complex/partial file formats. Another good usecase is just pure drawing/animation. This code will look identical on macOS and iOS and is very easy to write with SwiftUI. Finally, the last thing that mostly works is just lists of content. Not table views, those aren’t very good yet. I’m talking about Twitter-like content, as in a media viewer in list form.
What doesn’t work well is anything that has to do with controls (either they look very ugly, the control doesn’t exist, or SwiftUI has no concept of some significant portion of the control). If you want to do like focus loops or right clicks or anything complicated, forget it. (Some of these are getting fixed piecemeal, but AppKit has like a thousand little things that make good apps and it’ll be a while before they are all fixed.)
By way of example, I actually have some small apps that show this off well. https://github.com/saagarjha/EffectivePower is a little view-only document shoebox style app. It’s 100% SwiftUI, has one main screen that is a hand-drawn graph, and some auxiliary UI. This makes it about as good as it could be for using the framework. Making the graph was a delight. Making it perform well was a little bit of work but not too bad. The document abstraction mostly works except SwiftUI expects me to be able to create new documents and I’m just a viewer app so I need to crash if you try to make a new document. The sidebar is a List, which is fine, but I actually wanted it to be a Table. However Table selection asserts right now if you update its selection faster than the NSTableView that backs it animated. Of course in SwiftUI there is no concept of animation duration so you can’t really stop this from happening. You can also zoom the graph in the app. On Monterey if you tried to zoom a couple of times the system magnification gesture just stopped working silently. On Ventura I believe they have fixed this, or at least it isn’t trivially broken anymore. This is common for SwiftUI.
By way of contrast, https://github.com/saagarjha/VirtualApple is also pretty simple but it’s 100% AppKit. I had originally written it in SwiftUI but it’s just not possible to make it be a good Mac citizen. It is “document based” but because it deals with multi-gigabyte VMs I can’t actually let it do the default document based behavior, which includes making hidden revisions whenever the files update (which means you get a dozen secret copies of the VM). In AppKit I can just turn this all off and still look identical to any other system app. (Caveat: if I want the recent files menu and don’t want to use a storyboard, this is actually not available even in AppKit without SPI). Also, I have a little configuration screen which is all buttons and checkboxes. AppKit lets me align it precisely how I want so it looks nice. In SwiftUI it would look pretty awful.