From 43a01ee5c4ad3fe5ae1d4885f92c5b17d50f1f23 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Wed, 11 Nov 2026 14:40:45 -0500 Subject: [PATCH] feat(mobile): support Mac Catalyst builds --- apps/mobile/README.md | 24 ++++++++++++++ apps/mobile/app.config.ts | 6 ++++ apps/mobile/native/SystemVolume.swift | 16 ++++++++++ apps/mobile/plugins/with-mac-catalyst.js | 40 ++++++++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 apps/mobile/plugins/with-mac-catalyst.js diff --git a/apps/mobile/README.md b/apps/mobile/README.md index 5ca7e20..9829442 100644 --- a/apps/mobile/README.md +++ b/apps/mobile/README.md @@ -56,3 +56,27 @@ tab reconciliation, so startup updates cannot replace the Library and Playlists sections with a flat tab list. Keep both behaviors when updating the dependency. After changing native modules or dependency patches, run `pod install` in `ios` and rebuild the development app. + +### Mac Catalyst + +On a Mac with Xcode and CocoaPods installed, generate the iOS project with +Catalyst enabled. Use a separate checkout for Catalyst builds, since prebuild +changes the generated iOS project and its dependency configuration. + +```sh +MAC_CATALYST=1 APP_VARIANT=development pnpm exec expo prebuild --platform ios --clean +open ios/*.xcworkspace +``` + +In Xcode, select the app scheme and the **My Mac (Mac Catalyst)** destination, +select your signing team, then build and run. For a Release build, use Xcode's +Archive action with the Catalyst destination. EAS's existing iOS profiles still +build iPhone/iPad apps. + +The Catalyst plugin enables the Xcode target and React Native's CocoaPods +patches. It disables precompiled React Native and Expo modules so dependencies +can compile for Catalyst. The Mac app derives a separate bundle identifier with +Apple's `maccatalyst.` prefix. System volume stays under macOS control. + +To return a checkout to ordinary iOS builds, rerun prebuild without +`MAC_CATALYST=1`. Keep `APP_VARIANT` consistent when starting Metro. diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts index 8aa6e7a..009f3d7 100644 --- a/apps/mobile/app.config.ts +++ b/apps/mobile/app.config.ts @@ -28,6 +28,12 @@ export default ({ config }: ConfigContext): ExpoConfig => { return { ...config, + plugins: [ + ...(config.plugins ?? []), + ...(process.env.MAC_CATALYST === "1" + ? ["./plugins/with-mac-catalyst"] + : []), + ], name: `${config.name}${nameSuffix}`, slug: config.slug!, scheme: variant === "production" ? "otunes" : `otunes-${variant}`, diff --git a/apps/mobile/native/SystemVolume.swift b/apps/mobile/native/SystemVolume.swift index 529544b..2c6458c 100644 --- a/apps/mobile/native/SystemVolume.swift +++ b/apps/mobile/native/SystemVolume.swift @@ -3,6 +3,7 @@ import MediaPlayer import UIKit internal import ExpoModulesCore +#if !targetEnvironment(macCatalyst) /// Bridges system volume without changing the playback audio session or player gain. final class SystemVolume: Module { private var volumeView: MPVolumeView? @@ -84,3 +85,18 @@ final class SystemVolume: Module { return ["volume": AVAudioSession.sharedInstance().outputVolume, "available": available] } } + +#else +// macOS owns system volume. Keep the bridge available without MPVolumeView. +final class SystemVolume: Module { + public func definition() -> ExpoModulesCore.ModuleDefinition { + Name("SystemVolume") + Events("onVolumeChange") + AsyncFunction("getState") { () -> [String: Any] in + ["volume": 0, "available": false] + } + AsyncFunction("setPlayerVisible") { (_: Bool) in } + AsyncFunction("setVolume") { (_: Double) in } + } +} +#endif diff --git a/apps/mobile/plugins/with-mac-catalyst.js b/apps/mobile/plugins/with-mac-catalyst.js new file mode 100644 index 0000000..efb1325 --- /dev/null +++ b/apps/mobile/plugins/with-mac-catalyst.js @@ -0,0 +1,40 @@ +const { + withPodfile, + withPodfileProperties, + withXcodeProject, +} = require("expo/config-plugins") + +// Opt in during prebuild so normal iOS builds keep their precompiled dependencies. +module.exports = (config) => { + config = withPodfileProperties(config, (config) => { + config.modResults["ios.buildReactNativeFromSource"] = "true" + config.modResults.EXPO_USE_PRECOMPILED_MODULES = "false" + return config + }) + + config = withPodfile(config, (config) => { + const pattern = /:mac_catalyst_enabled\s*=>\s*(?:false|true)/ + if (!pattern.test(config.modResults.contents)) { + throw new Error("Cannot enable Catalyst: Expo's Podfile template has changed") + } + config.modResults.contents = config.modResults.contents.replace( + pattern, + ":mac_catalyst_enabled => true" + ) + return config + }) + + return withXcodeProject(config, (config) => { + const project = config.modResults + const target = project.getFirstTarget().firstTarget + const lists = project.pbxXCConfigurationList() + const configurations = project.pbxXCBuildConfigurationSection() + for (const { value } of lists[target.buildConfigurationList].buildConfigurations) { + const settings = configurations[value].buildSettings + settings.SUPPORTS_MACCATALYST = "YES" + settings.DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = "YES" + settings.TARGETED_DEVICE_FAMILY = '"1,2"' + } + return config + }) +} -- 2.54.1