macOS Apprentice
I’ve written another book! This one is for people who want to get started in macOS development and here it is: macOS Apprentice, published by kodeco.com (formerly raywenderlich.com).
If you’re a beginner or near-beginner who wants to start learning Swift, SwiftUI and AppKit for building Mac apps, then this is the book for you.
It’s good to have an updated beginner book. When to use AppKit vs. SwiftUI, and how to mix them, is an area that Apple itself hasn’t discussed much. Her recommendation:
- To support old versions of macOS, use AppKit.
- For long-form text editing or for thousands of records, use AppKit.
- For existing AppKit apps, add SwiftUI gradually.
- For everything else, start with SwiftUI and include AppKit as needed.
I have not seen a comprehensive survey of which features are unavailable in each environment.
Previously:
- Setting Up Sparkle
- Guides for Starting Apple App Development
- Testing SwiftUI for Mac After WWDC 2022
- SwiftUI for Mac on Big Sur
- SwiftUI for Mac
7 Comments RSS · Twitter · Mastodon
I still believe AppKit and Objective-C remain the best way to develop an app that produces the Mac experience. AppKit is the most complete, most mature framework for Apple Desktop dev. AppKit is primarily ObjC and forcing Swift onto it just gives you impedance mismatches, performance round-trips, dumb errors, and needless complexity just so you can say you're "Swifty".
In my view, recommending Swift+SwiftUI for Mac apps is like recommending C++ and Carbon for Mac Apps. It was possible for such an app to match the quality of an ObjC+AppKit app IF the dev was willing to implement a lot of missing behaviors and features. Most devs didn't (or were not aware of the little things AppKit did) so the end result was Carbon generating "lesser" Mac Apps. I view SwiftUI as worse, because it still has critical bugs. Year 3 of the Apple chasing the dying React trend, not Mac OS X DP3, but it somehow gets a recommendation from everyone.
What are some Swift+SwiftUI Mac apps that one-up ObjC+AppKit apps in the way that ObjC+AppKit one-upped Carbon apps? What does Swift+SwiftUI do to make an improved Mac experience for the end-user? I don't care about cross platform claims, or non-standard platform animations, or Apple marketing. How does Swift+SwiftUI produce superior Mac Apps?
“ How does Swift+SwiftUI produce superior Mac Apps?”
It doesn’t.
“ -To support old versions of macOS, use AppKit.
-For long-form text editing or for thousands of records, use AppKit.
-For existing AppKit apps, add SwiftUI gradually.
-For everything else, start with SwiftUI and include AppKit as needed.”
For the last two why? I can’t think of any reason other than the fact that Apple Management says so. Mac apps have dealt with a variety of screen sizes long before SwiftUI and even Autolayout just fine.
I dragged out a multiline label in Interface Builder and made an NSPopover with it in about 2 seconds a few weeks ago. It was so easy it’ll make you cry. I used to make like 4 to 5 Mac apps a year now I might just leave the platform
Hi Gary,
The basic Swift in the book applies to all Apple platforms and some of the SwiftUI, but the Mac specific code is not relevant to the Vision Pro.
@Hammer @ObjC4Life : agreed.
I've used Swift. Had to, for a client's project. I got the spirit of it, but had to work around all sorts of performance regressions. Overall, objective C was better. And this is from someone who's favorite language for developing complex algorithms is Haskell (I've been using it since its inception -- anyone remember the LML compiler bootstrapped to work with Haskell?), so it's not like I have a problem with the functional paradigm. But Objective C was an elegant weapon from a more civilized age, and all that.
Firstly, thank you Sarah for writing this book. I bought it yesterday and read half of it in an afternoon (just reading). I intend to finish reading it today, and then start on the demo project later this week. It is exactly what I was looking for, a crash course on building Mac apps with Swift and SwiftUI, so thank you.
I am more familiar with Objective-C than Swift and the last time I tried to do anything with Swift, it turned out easier to stick with Obj-C. I've read about the performance disparities and the lack of swizzling.
IMHO, whether you like it or not, Swift and SwiftUI is where I think Apple is heading. SwiftUI looks incredible, with a lot of potential, I honestly can see this as the way forwards especially with x-plat development. You worry about the overall design & layout and let SwiftUI sweat the platform specific details.