ArchiveExpo SnackDiscord and ForumsNewsletter

Additional platform support

Learn how to add support for macOS and tvOS platforms.

Expo Modules API provides first-class support for Android and iOS. However, since all Apple platforms are based on the same foundation and use the same programming language, targeting other Out-of-Tree platforms in the Expo module is possible. At the moment, only macOS and tvOS platforms are supported. This guide will walk you through adding support for these platforms.


Use the "apple" platform in expo-module.config.json

To provide seamless support for other Apple platforms, Expo SDK 50 introduced a universal "apple" platform to instruct the autolinking that the module may support any of the Apple platform and the question whether to link the module in the specific CocoaPods target is moved off to the podspec. If you have used "ios" before, you can safely replace it:

-   "platforms": ["ios"],
-   "ios": {
-     "modules": ["MyModule"]
-   }
+   "platforms": ["apple"],
+   "apple": {
+     "modules": ["MyModule"]
+   }


Update the podspec to declare support for other platforms

The module's podspec needs to be updated with a list of the supported platforms. Otherwise, CocoaPods would fail to install the pod on targets for the other platforms. As mentioned in the first step, this part of the spec is the source of truth for autolinking when the module is configured with a universal "apple" platform.

Module's podspec
- s.platform       = :ios, '13.4'
+ s.platforms = {
+   :ios => '13.4',
+   :tvos => '13.4',
+   :osx => '10.15'
+ }

Any changes in the podspec require running pod install to have an effect.


Set up react-native-macos or react-native-tvos in the app

If you are writing a local module and your app is already set up, you can skip this step. Otherwise, you will need to set up your app or the example app if you are writing a standalone (non-local) module.

  • For macOS: follow the official Install React Native for macOS guide from react-native-macos documentation.
  • For tvOS: follow the instructions in the react-native-tvos repository. If you are building an Expo app, you should also follow the instructions in our Building Expo apps for TV guide.


Review the code for using APIs not supported on these platforms

Platform APIs may differ between Apple platforms. The most noticeable difference comes from relying on different UI frameworks —UIKit on iOS/tvOS and AppKit on macOS.

Both react-native-macos and expo-modules-core provide aliases and polyfills to referenceUIKit classes on macOS target (for example, UIView is an alias to NSView, UIApplication is an alias to NSApplication), but it's usually not enough for iOS-first libraries to support other platforms out of the box. You may need to write conditionally compiled code that uses different implementations depending on the platform.

To do this, use Swift compiler directives with the os condition, which includes a given piece of code when our app is being built for a specific platform. In combination with the #if and #else directives, lets you set up platform-specific branches within the cross-platform code.

#if os(iOS)
  // iOS implementation
#elseif os(macOS)
  // macOS implementation
#elseif os(tvOS)
  // tvOS implementation

Your module is now ready to be used on Out-of-Tree platform.