Version Second Edition
Platform iOS 14
Language Swift 5.3
Editor Xcode 12.2

Run iOS apps natively on macOS with Catalyst!

Catalyst by Tutorials shows you how to take all of those great apps you’ve build on iOS and run them right on macOS. But like everything else with Apple, it’s not always as straightforward as you’d like it to be. This book will show you how to design your apps to work well on macOS, what you can and can’t port between the two platforms, and any other “gotchas” to keep an eye out for when building apps under Catalyst.

This book is for developers who have a good handle on building iOS apps and want to learn how to port those apps to run on macOS as well.

What Is Catalyst?

Formerly known as Marzipan to Apple insiders, Catalyst lets you extend your iPad apps to macOS. Under Catalina and Xcode 11, developers can now build their iPad apps with macOS as a target.

And we’re not just talking about grossly super-sized versions of iPad apps on your Mac; Catalyst apps will support native macOS controls and functionality, such as the familiar menu bar, support for mouse and keyboards, window resizing, proper scroll bars, Touch Bar support, and desktop-based drag and drop.

So if you’ve been hesitating to port your iPad apps to macOS because you just don’t want to have to learn to develop for the desktop, then 2019 is your year!

Before You Begin

This section tells you a few things you need to know before you get started, such as what you’ll need for hardware and software, where to find the project files for this book, and more.

i

iii

iv

Section I: Making a Great iPad App

Catalyst is all about letting you use code you’ve written for iOS on macOS. But not just any code. At least for now, you can only run code that is written for iPad on a Mac. And because most of the code will run on both platforms, before you dive in to running your app on your Mac, there are a few things you should do to make your code ready.

In this section, you’ll take an app written to run on iPhone and adapt it to run on iPad. Then you’ll add some features to make it behave like a first-class iPad citizen. And through the magic of Catalyst, these features will make your Mac app better too!

In this chapter, you're going to get your first look at the sample app that you'll be interacting with for the remainder of this book. Once you familiarize yourself with the basic functionality and architecture, you'll take your first steps toward bringing the app to macOS.

1

Here, learn why you should use Split View Controller and gain Instruction on how to migrate from iPhone-style Navigation Controller with master/detail push to Split View Controller.

2

In this chapter, you'll learn how to add support for dragging photos from other apps and dropping them into your app. You'll also learn how to implement drag and drop for collection views with smooth animations and cell reordering.

3

In this chapter, you'll learn how to enable a feature that has been available since the beginning on the Mac, and has just arrived with iOS 13 on the iPad, multi-window support.

4

In this chapter, you're going to learn all about context menus, adding support for long-press menus on iPad and how those menus will automatically port to Mac.

5

In this chapter, learn how to use keyboard commands to navigate across a list and delete items, as well as the UIKeyCommand and setting first responder.

6

Learn layout preferences, and override individual items from dark mode, similar to Mail.app and the reader pane.

7

Section II: Making a Great Mac App

The good news is that most of your code will be useful for both iPad and Mac platforms. But what about the things that are Mac-specific: like mouse support, Touch Bar support and more?

In this section, you’ll take the first-rate iPad app from the previous section and add Mac-specific touches to make it work well on macOS.

In this chapter, you're going to take things to the next level by making some adjustments that will really make your app shine when running on macOS via Catalyst. Throughout the rest of this section, you'll go deeper on several other Mac-specific features. When you're done, you'll have the makings of a world-class Mac app.

8

Use UIHoverGestureRecognizer to show a shadow effect when hovering over a diary entry in the sample app.

9

In this chapter, you’ll learn all about the menu bar by trimming the default menu bar, as well as adding new items to delete, share and add new diary entries.

10

In this chapter, you'll learn to customize the toolbar items, including Share, Insert and Print.

11

In this chapter you'll continue to develop your app by adding the toolbar items to the Touch Bar.

12

Section III: Distributing Your App

Congratulations! You now have a Mac app. But getting that app to your users can be a little different than on iOS.

In this section, you’ll learn the options for distributing your app and how those options work.

In this chapter, you’ll read about the pros and cons of distributing on the Mac App Store, and learn how to go from Xcode all the way to a released app on the App Store.

13

In this chapter, you’ll learn how to make sure everyone with macOS can run your app, as well as how to improve the installation experience for your potential users.

14

Meet the team

Contributors

Who is this book for

This book is for developers who have a good handle on building iOS apps and want to learn how to port those apps to run on macOS as well.

Concepts covered in this book

  • Multi-Window Support
  • Drag-and-Drop API
  • Context menus
  • Keyboard shortcuts
  • App preferences
  • Mouse support
  • Toolbar & TouchBar
  • Distribution differences between macOS and iOS apps

Version history

Second Edition · iOS 14, Swift 5.3, Xcode 12.2

v2.0 · Oct 1 2020 · Marin Bencevic, Andy Pereira & Nick Bonatsakis

First Edition · iOS 13, Swift 5.1, Xcode 11

v1.0 · Oct 2 2019 · Marin Bencevic, Nick Bonatsakis & Andy Pereira
Pro

Catalyst by Tutorials

By Marin Bencevic, Andy Pereira and Nick Bonatsakis

Take all of those great apps you’ve build on iOS and learn how to make them run well under macOS using the Catalyst framework.

Read for Free with an Ultimate Pro Subscription* * Includes this and all other books in our online library See all benefits
Buy Individually $59.99 $29.99* *Includes access to all of our online reading features.
See buying options
Hide buying options

All videos. All books.
Now 50% off.

Build your mobile development skills and save! The mobile development world moves quickly — and you don't want to get left behind. Stay ahead of the rest with an Ultimate book & video subscription. Starting at just $149/year for Black Friday.