Skip to content

Commit bc5b4d3

Browse files
Saadnajmiclaude
andcommitted
Fix macOS SPM build: conditionally exclude iOS/macOS switch files
IOSSwitchShadowNode.mm imports UIKit which doesn't exist on macOS. Use #if os(macOS) to exclude the iOS variant and include the macOS variant (and vice versa on iOS), matching the existing pattern for view platform sources. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f20a4a6 commit bc5b4d3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/react-native/Package.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,11 @@ let reactCore = RNTarget(
385385
#if os(macOS)
386386
let reactFabricViewPlatformSources = ["components/view/platform/macos"]
387387
let reactFabricViewPlatformExcludes = ["components/view/platform/cxx"]
388+
let reactFabricComponentsSwitchExcludes = ["components/switch/iosswitch/react/renderer/components/switch/IOSSwitchShadowNode.mm"]
388389
#else
389390
let reactFabricViewPlatformExcludes = ["components/view/platform/macos"]
390391
let reactFabricViewPlatformSources = ["components/view/platform/cxx"]
392+
let reactFabricComponentsSwitchExcludes = ["components/switch/iosswitch/react/renderer/components/switch/MacOSSwitchShadowNode.mm"]
391393
#endif
392394
// macOS]
393395
let reactFabric = RNTarget(
@@ -446,7 +448,7 @@ let reactFabricComponents = RNTarget(
446448
"components/view/platform/android",
447449
"components/view/platform/windows",
448450
"components/view/platform/macos",
449-
"components/switch/iosswitch/react/renderer/components/switch/MacOSSwitchShadowNode.mm",
451+
// "components/switch/iosswitch/.../MacOSSwitchShadowNode.mm" or "IOSSwitchShadowNode.mm" — [macOS] see reactFabricComponentsSwitchExcludes
450452
"components/textinput/platform/android",
451453
"components/text/platform/android",
452454
"components/textinput/platform/macos",
@@ -457,7 +459,7 @@ let reactFabricComponents = RNTarget(
457459
"textlayoutmanager/platform/windows",
458460
"textlayoutmanager/platform/macos",
459461
"conponents/rncore", // this was the old folder where RN Core Components were generated. If you ran codegen in the past, you might have some files in it that might make the build fail.
460-
],
462+
] + reactFabricComponentsSwitchExcludes, // [macOS]
461463
dependencies: [.reactNativeDependencies, .reactCore, .reactJsiExecutor, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .yoga, .reactRendererDebug, .reactGraphics, .reactFabric, .reactTurboModuleBridging],
462464
sources: ["components/inputaccessory", "components/modal", "components/safeareaview", "components/text", "components/text/platform/cxx", "components/textinput", "components/textinput/platform/ios/", "components/unimplementedview", "components/virtualview", "textlayoutmanager", "textlayoutmanager/platform/ios", "components/switch/iosswitch"]
463465
)

0 commit comments

Comments
 (0)