Skip to content

fix(macos): expose React-RCTUIKit module to RCTSwiftUI Swift consumers - #2958

Closed
Thiago Vinhas (tvinhas) wants to merge 1 commit into
microsoft:0.83-mergefrom
tvinhas:fix-rctswiftui-import-react-rctuikit
Closed

fix(macos): expose React-RCTUIKit module to RCTSwiftUI Swift consumers#2958
Thiago Vinhas (tvinhas) wants to merge 1 commit into
microsoft:0.83-mergefrom
tvinhas:fix-rctswiftui-import-react-rctuikit

Conversation

@tvinhas

Copy link
Copy Markdown

Summary

Wires the React-RCTUIKit pod into RCTSwiftUI so RCTSwiftUIContainerView.swift can import the ObjC-side @compatibility_alias declarations (RCTPlatformView, RCTUIColor) directly, instead of carrying its own Swift typealias
shadow copies of those names.

Two files, two coupled changes — must ship together. Removing the Swift typealiases without first wiring the pod dep would leave the Swift file with no source for RCTPlatformView / RCTUIColor and break compilation.

1. RCTSwiftUI.podspec — add React-RCTUIKit dependency

s.dependency"React-RCTUIKit"ThisputstheReact_RCTUIKitclangmoduleontheSwiftmodulesearchpathwhenRCTSwiftUIContainerView.swiftbuilds.Unconditional(not s.osx)forparitywiththerestoftheapplepodsthedepisharmlessoniOSsincetheumbrellaheadersaremostlytypedef-onlythere.2.RCTSwiftUIContainerView.swiftimportthemodule,dropduplicatetypealiasesBefore:
importSwiftUI#if os(macOS)importAppKit#elseimportUIKit#endif#if os(macOS)publictypealiasRCTPlatformView=NSViewpublictypealiasRCTUIColor=NSColorpublictypealiasRCTPlatformHostingController=NSHostingController#elsepublictypealiasRCTPlatformView=UIViewpublictypealiasRCTUIColor=UIColorpublictypealiasRCTPlatformHostingController=UIHostingController#endifAfter:
importSwiftUIimportReact_RCTUIKit//[macOS]pullsin@compatibility_aliasRCTPlatformView / RCTUIColor#if os(macOS)importAppKit#elseimportUIKit#endif#if os(macOS)publictypealiasRCTPlatformHostingController=NSHostingController#elsepublictypealiasRCTPlatformHostingController=UIHostingController#endifRCTPlatformViewisnowsourcedfromRCTUIView.h:28-33(@compatibility_aliasRCTPlatformViewUIView/NSView);RCTUIColorfromRCTUIKitCompat.h:25-29.RCTPlatformHostingControllerstaysasaSwifttypealiasit's NSHostingController /UIHostingController from SwiftUI, parameterized by view type, not in the ObjC compat layer.Closes the "RCTUIKit Swift module" item on the Road to 0.83 tracking issue (#2901) — Saad'snotethere: "RCTUIKit.h can't be imported from Swift (needed by RCTSwiftUIContainerView.swift). Already broken out into its own module on main,needs rebase into 0.83-merge."Themodule-ificationitselfwasalreadybroughtinbythe0.83-mergeupstreampull;whatwasmissingwastheconsumer-sidewiringonRCTSwiftUI,whichthisPRadds.TestPlan
- podinstallinpackages/rn-testeron0.83-mergeresolvesthenewdepedgecleanly: Podfile.locknowrecordsRCTSwiftUI(1000.0.0): - React-RCTUIKit,andReact-RCTUIKitalreadyappearsatline2262asatop-levelpod.Specchecksumbumpedfrom97b5f3…toc47667….86dependencies / 85installed,noresolutionerrors.(Validatedlocally.)
- SourceKitreportsNosuchmodule'React_RCTUIKit'untilpodinstallruns(theworkspacedoesn't know about the dep before install). After install, the workspace materializes React_RCTUIKit and the import resolves. This is the standardpre-install state on any clean checkout, not a regression.- The Swift file'sonlyconsumersofthedroppedtypealiasesarelocalreferencesinsidethesamefileverifiedthefilestilltype-checksatthelanguagelevel(usesmatchtheObjC@compatibility_aliastypesexactly).Related
- #2847 — the original RCTUIKit module-ification on main (now needed on 0.83-merge too — already merged in via the upstream pull, this PR completes the consumer wiring)
- #2901 — Road to 0.83 tracking issue (closes the RCTUIKit Swift module item)

Comment on lines +9 to +19
// [macOS] Pull in the ObjC @compatibility_alias declarations for
// `RCTPlatformView` (UIView/NSView) and `RCTUIColor` (UIColor/NSColor)
// from RCTUIKit. Without this import the Swift file used to re-declare
// these as local `public typealias`es, which shadowed the ObjC aliases
// and forced every consumer of this module to choose between the Swift
// and ObjC name. After the React-RCTUIKit pod dep is wired in
// RCTSwiftUI.podspec, the import is the canonical source of truth.
// `RCTPlatformHostingController` stays as a Swift typealias below — it
// wraps NSHostingController / UIHostingController which are SwiftUI
// generics and not in the ObjC compat layer.
import React_RCTUIKit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this giant comment

Saad Najmi (Saadnajmi) pushed a commit that referenced this pull request Jun 18, 2026
)
## Summary
`packages/react-native/package.json` lists three macOS-fork podspecs in
the `files` array — `React-Core.podspec`, `React-Core-prebuilt.podspec`,
`React.podspec` — but **omits `React-RCTUIKit.podspec`**, which was
introduced by #2847
(RCTUIKit module-ification, merged March 2026). As a result the file
lives in the source tree but is excluded from the npm publish.
Any downstream consumer of a published \`react-native-macos@0.83\` hits
this immediately:
\`\`\`
[!] No podspec found for \`React-RCTUIKit\` in
\`../node_modules/react-native-macos/\`
\`\`\`
\`pod install\` fails before reaching any actual install step.
Discovered while running
[react-native-test-app](https://github.com/microsoft/react-native-test-app)'s
\`example-macos\` against the fork's \`0.83-merge\` via a local
Verdaccio registry — the file shows up in the source tree
(\`packages/react-native/React-RCTUIKit.podspec\`) but never lands in
\`node_modules/react-native-macos/\` after install.
Fix is a one-line addition to the \`files\` array, right next to the
other root-level podspecs. Closes the consumer-install gap for any
downstream user (RNTA, Epistles, anyone else) once 0.83 ships to npm.
## Test Plan
- **Before:** \`npm pack\` on \`packages/react-native\` produces a
tarball without \`React-RCTUIKit.podspec\`. RNTA's \`example-macos\`
\`pod install\` fails with "No podspec found for React-RCTUIKit".
- **After:** \`npm pack\` includes the file; \`pod install\` resolves
the React-RCTUIKit pod from
\`../node_modules/react-native-macos/React-RCTUIKit.podspec\` and
continues. Validated locally with RNTA's \`example-macos\` building
cleanly through to a \`ReactTestApp.app\` artifact.
## Related
- #2847 — introduced \`React-RCTUIKit.podspec\` (and the corresponding
\`React-RCTUIKit\` pod dep in \`React-Core.podspec\`), but didn't update
the \`files\` array.
- #2958 — wires \`React-RCTUIKit\` into \`RCTSwiftUI.podspec\`; depends
on this podspec being available to consumers.
- #2901 — Road to 0.83 tracking issue (unblocks downstream consumers in
general).
@Saadnajmi

Copy link
Copy Markdown
Collaborator

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

not stale

@Saadnajmi

Copy link
Copy Markdown
Collaborator

not stale

@Saadnajmi

Copy link
Copy Markdown
Collaborator

Closing in favor of #3006

Saad Najmi (Saadnajmi) added a commit that referenced this pull request Jul 7, 2026
## Summary:
Followup to #2958 ,
whose repo is still locked so we can't edit it.
Extend RCTUIKit support to SwiftUI
## Test Plan:
CI should pass
Saad Najmi (Saadnajmi) pushed a commit that referenced this pull request Jul 13, 2026
)
## Summary
`packages/react-native/package.json` lists three macOS-fork podspecs in
the `files` array — `React-Core.podspec`, `React-Core-prebuilt.podspec`,
`React.podspec` — but **omits `React-RCTUIKit.podspec`**, which was
introduced by #2847
(RCTUIKit module-ification, merged March 2026). As a result the file
lives in the source tree but is excluded from the npm publish.
Any downstream consumer of a published \`react-native-macos@0.83\` hits
this immediately:
\`\`\`
[!] No podspec found for \`React-RCTUIKit\` in
\`../node_modules/react-native-macos/\`
\`\`\`
\`pod install\` fails before reaching any actual install step.
Discovered while running
[react-native-test-app](https://github.com/microsoft/react-native-test-app)'s
\`example-macos\` against the fork's \`0.83-merge\` via a local
Verdaccio registry — the file shows up in the source tree
(\`packages/react-native/React-RCTUIKit.podspec\`) but never lands in
\`node_modules/react-native-macos/\` after install.
Fix is a one-line addition to the \`files\` array, right next to the
other root-level podspecs. Closes the consumer-install gap for any
downstream user (RNTA, Epistles, anyone else) once 0.83 ships to npm.
## Test Plan
- **Before:** \`npm pack\` on \`packages/react-native\` produces a
tarball without \`React-RCTUIKit.podspec\`. RNTA's \`example-macos\`
\`pod install\` fails with "No podspec found for React-RCTUIKit".
- **After:** \`npm pack\` includes the file; \`pod install\` resolves
the React-RCTUIKit pod from
\`../node_modules/react-native-macos/React-RCTUIKit.podspec\` and
continues. Validated locally with RNTA's \`example-macos\` building
cleanly through to a \`ReactTestApp.app\` artifact.
## Related
- #2847 — introduced \`React-RCTUIKit.podspec\` (and the corresponding
\`React-RCTUIKit\` pod dep in \`React-Core.podspec\`), but didn't update
the \`files\` array.
- #2958 — wires \`React-RCTUIKit\` into \`RCTSwiftUI.podspec\`; depends
on this podspec being available to consumers.
- #2901 — Road to 0.83 tracking issue (unblocks downstream consumers in
general).
Saad Najmi (Saadnajmi) added a commit that referenced this pull request Jul 13, 2026
## Summary:
Followup to #2958 ,
whose repo is still locked so we can't edit it.
Extend RCTUIKit support to SwiftUI
## Test Plan:
CI should pass
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@tvinhas@Saadnajmi