Ask HN: Book Recommendation for macOS Development

86 points by soapdog ↗ HN
Hi Folks,

I'm trying to get back into macOS application development. I used to know the basics of Objective-C and Cocoa stuff back on the early days of Mac OS X with big cat names. At the time, I got a lot of value from the Cocoa Programming book from Big Nerd Ranch.

These days, it seems that every book about programming for Apple platforms is focused on iOS. Don't get me wrong, I love my iPad, but I'd rather develop desktop apps.

It appears to me that the documentation site has been neglected, and that the search engine algorithms favour returning videos and quick tutorials over books. Anyway, I'm having a hard time figuring out a good recent book about developing desktop apps for macOS. I don't care if it is Swift or Objective-C, I like both.

Can someone here point me in a good direction?

Thanks.

20 comments

[ 2.9 ms ] story [ 51.3 ms ] thread
There aren’t any, the market for native Mac development is too small to support a good published book.

You will be spending inordinate amounts of time in the Documentation Archive reading still applicable (and well written) docs, on S/O reading the ~3 threads that relate to your issue, blog posts from ~2010 and a whole lot of time searching specific APIs w/ GH code search to see how a repo from 2014 used it. And you’ll be alone in time and space if you’re not at a co while doing it.

Web developers are far more common, far cheaper, and far better supported by the ecosystem, you can literally just plug and play them entirely unlike eg iOS developers -> AppKit.

If this is a personal thing, have fun it’s very rewarding. If this is business/career, either learn Mandarin or turn around now, there is no hope or future here.

The funny thing is that when I first brought home a book on Cocoa programming in the mid-2000s, my dad (also a programmer) saw it and gave me almost an identical line to your last sentence. He said it was a waste of time, that I'd never make money doing it, and the market for Mac developers was tiny.

I've been doing Mac (and sometimes iOS) development almost ever since and as of right now make almost 2x my dad's career-high salary. That tiny market has treated me very well.

Every single Mac focused developer I’m aware of started pre or around 2010 as well, including me, for a reason.

Riding a peak in a self admitted niche market all the way down and then recommending it to others as you yourself exit your career isn’t evidence, it’s irresponsible.

The simple fact you had a book on Cocoa programming written in the past decade (and official programming guides, offline/online discussion groups, WWDCs with more than a handful of events) should tell you something about the relative difference in the market since then.

The market situations does not look as dire to me as it does to finiteseries; the audience is as large as ever and there are Mac-only developers doing perfectly fine.

The problem specifically with books is more that developer attention is split between Catalyst (UIKit), SwiftUI, and (AppKit | UIKit), and if you’re going to document something in this space, everything that isn’t AppKit has a larger audience.

But I do need to point out that AppKit is now in the position Carbon was in during the 2000’s — the future on macOS, if there is one, is evidently UIKit via Catalyst or SwiftUI no matter what assurances Apple makes. I would not advise a new developer to learn AppKit at this point in time.

> I would not advise a new developer to learn AppKit at this point in time.

I've been contracting on a "modern" mac app in SwiftUI for the last few months, one of the issues I see is that you can't actually get that far without AppKit right now unless you have the luxury of supporting only the latest macOS. Even then people often just don't upgrade their OS until they buy a new computer so you're stuck with whatever version of SwiftUI. It's a bit of a weird time for macOS development.

I like SwiftUI a lot, but IMO it's not really ready for primetime yet, while trying to do something partly in SwiftUI and partly in UIKit is ugly, ugly, ugly (again, IMO).
Why do you think it’s ugly? What makes it so?

I’ve bridged several UIKit components into SwiftUI and it’s been fine. You have to be careful with Auto Layout, my approach was to divide into separate UIView and then wrap those in UIViewRepresentable, thus leaving the layout to SwiftUI. But that was the main thing to keep in mind.

I was recently contracted to help with a (very small!) Mac app written in SwiftUI where they had hit a hard wall on implementing a couple fundamental UI features and needed that part of the UI rewritten in AppKit. "That part of the UI" is about 80% of the surface area of the apps' main window. (Worth noting that the app current deploys to macOS 12, so even the latest deployment target isn't good enough to get us there.)

AppKit may go away eventually, but _today_ it's still required to write a good Mac app even if you can use SwiftUI for large portions.

My experience on this project has also taught me that AppKit can be made to play quite nicely with SwiftUI. The AppKit code is encapsulated well, and from the outside gets instantiated and included exactly as if it were a SwiftUI component.

This essentially mirrors my experience however the codebase is more around 50-50 split AppKit / SwiftUI, most controls we tend to use AppKit and layout and display SwiftUI. I don't actually think the integration is too painful, layout can be a little weird sometimes where the two worlds awkwardly join but you can work around most issues there.
> UIKit via Catalyst

Catalyst is clearly an interim solution for a fairly narrow group of developers. If someone is planning on targeting macOS only then they can ignore it.

I work on a large, complex, well-respected iOS app. Some of our main competition is desktop apps, and we've often been asked for a macOS version. M1 Macs can run our app natively now, and we've done some work to make that a better experience than it would be by default. We've also spend some time seeing about using Catalyst to bring the app to the Mac for real.

As a longtime Mac developer, I'm not super impressed. It's cool to get a build going for macOS quickly, but the effort required to make a non-trivial Catalyst app not suck turns out to be very significant.

I would definitely not even dream of using it to build a Mac-first/Mac-only app. The (debatable) advantages of UIKit over AppKit are just not even close to enough to outweigh the difficulty involved in making a good Catalyst app. The benefit of Catalyst is bringing an existing iOS codebase over and/or sharing code between platforms. It is not a better way to make a Mac app on its own merits.

(comment deleted)
I also read the Cocoa Big Nerd Ranch guide, and wish they'd do another. Alot of those concepts are not entirely gone, and can still be put to use. If you already know a bit of Obj-C and AppKit, then I'd recommend hackingwithswift.com. He has a great number of tutorial series on Swift, SwiftUI, and iOS and Mac programming. He also has a paid mini course I believe. Other than that, it's a pretty guerilla effort, but it is fun
I'd add to this in particular that making things like more sophisticated menubar apps require the use of a bit of objective-c, appkit, Swift, and SwiftUI optionally
This might not be exactly what you’re looking for, but I read the “big nerd ranch guide to iOS programming” which was a really great book for learning iOS development. I then built an app for iOS and found that bringing it to macOS was very simple using catalyst. Mac now makes up 1/3 of my (very tiny) revenue. So, that might be one way for you to go, with the added benefit that you’ll know how to build iOS apps as well as Mac apps.
I would start with SwiftUI. Aiming where the ball is going not where it is.
I’m an iOS dev, but I have developed some macOS apps for internal use using AppKit: I’d like to think they were pretty good apps if not quite production ready. I think the Big Nerd Ranch Cocoa Programming Guide for OSX is still the best book out there. The version I have is from 2015 which targets Swift 1.2 and Yosemite: you might actually be better off with an earlier version that targets Objective-C as Swift has changed quite a lot since then. If you go through the Big Nerd Ranch book you’ll have enough to use the start using the official documentation effectively. AppKit is very old for sure, and has a lot of weird corners, but you can be incredibly productive with it: and there is still a lot more Interface Builder “magic” developing for macOS than there is with iOS. Combined with the brilliance of the Foundation stdlib it can be a pleasure. My own experience is that if you avoid fighting AppKit you’ll have a very productive time. I wouldn’t support some of the recommendations for SwiftUI and Catalyst. As other commenters have noted you’ll have to “drop down” to AppKit anyway to create a good app.