feat(mobile): support Mac Catalyst builds #81
No files matched your search
@@ -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.
|
||||
@@ -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}`,
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user