Two techniques to access AppKit from Catalyst apps in pure Swift

Mac Catalyst & macOS
Mac Catalyst & macOS
Image source: Author

Only a small part of AppKit API is available to Mac Catalyst, but since Mac Catalyst apps are also macOS apps, they do have full access to AppKit API in runtime. It’s just not visible to them because Apple marked most of the AppKit classes as unavailable to Catalyst apps.

In this article, we’ll see how we can access AppKit API from Mac Catalyst apps in two different ways and in pure Swift.

A. Using Dynamic

A simple, clean, and safe way to call hidden API in Swift 5

Photo by Gwendal Cottin

Making private API visible in Swift is a tedious job. You have to find the private headers, copy them to your project, create a bridging header file, and import the private headers. Or you can use message sending techniques to perform a method selector on a target object, and extract the returned value and convert it to a Swift type.

In this post, we’ll see how we can use the Swift attributes @dynamicMemberLookup and @dynamicCallable to create a wrapper around Objective-C classes and objects, and then use method invocation to access their properties and methods. …

Although macOS and Catalyst are not officially supported by Firebase, yet, some services can be used in macOS apps right now. I’ll explain how to connect Firebase with macOS apps and set up Crashlytics.

Set up the Firebase Project

Create a Firebase project and set up the app as an iOS app. After you finish the setup and run the app, you’ll notice that the Firebase console is still waiting to verify the installation.

Mhd Hejazi

Mobile App Developer & UI/UX Designer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store