Skip to content

fix(iOS): hide react symbols from swift#4224

Open
radoslawrolka wants to merge 7 commits into
software-mansion:mainfrom
radoslawrolka:rolkrado/hide-react-from-swift
Open

fix(iOS): hide react symbols from swift#4224
radoslawrolka wants to merge 7 commits into
software-mansion:mainfrom
radoslawrolka:rolkrado/hide-react-from-swift

Conversation

@radoslawrolka

@radoslawrolka radoslawrolka commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Description

In RNRepo, when an app consumes react-native-screens as a prebuilt XCFramework, the iOS build fails with errors like 'React/RCTEventDispatcherProtocol.h' file not found and could not build Objective-C module 'RNScreens'.

Root cause: RNScreens 4.25.0 introduced Swift code for the first time, which makes the build emit a .swiftinterface containing @_exported import RNScreens. When a Swift consumer (e.g. expo-router's LinkPreviewNativeNavigation.swift) does import RNScreens, the Swift compiler parses that swiftinterface and triggers a recompilation of the Objective-C RNScreens module from the XCFramework's public headers. Those public headers #import <React/...> (and reference RCT* types), but the Swift recompilation doesn't need the acces to the RN symbols, so we can hide them behind #if defined(__cplusplus) guards.

Changes

Hidden all RCT* and #import <React/ in public headers behind #if defined(__cplusplus) guards.

Test plan

workflows launched on fork, but all branches and hashes can be checked

Checklist

  • Included code example that can be used to test this change.
  • Ensured that CI passes

@radoslawrolka radoslawrolka marked this pull request as ready for review June 29, 2026 07:51
@radoslawrolka radoslawrolka marked this pull request as draft July 1, 2026 09:52
@radoslawrolka radoslawrolka marked this pull request as ready for review July 1, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant