Skip to content

Skip third-party components whose class is not linked instead of crashing at launch - #59067

Closed
YevheniiKotyrlo wants to merge 1 commit into
react:mainfrom
YevheniiKotyrlo:fix/component-provider-missing-class
Closed

YevheniiKotyrlo wants to merge 1 commit into
react:mainfrom
YevheniiKotyrlo:fix/component-provider-missing-class

Conversation

@YevheniiKotyrlo

Copy link
Copy Markdown
Contributor

Summary:

RCTThirdPartyComponentsProvider.mm builds its component map from a dictionary literal of NSClassFromString results. When a component's library is not linked into the target, such as an app extension or App Clip that leaves a library out (#56469), or a macOS app whose dependencies include an iOS-only component library (react-native-macos generates the same file), NSClassFromString returns nil and the literal throws at launch:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'

The provider now maps component names to class names and registers the classes the runtime has, the way RCTModuleProviders.mm already handles a module provider that cannot be found. A component left out this way falls back to <UnimplementedView> if it is rendered, as an unknown component does.

Changelog:

[IOS] [FIXED] - Skip third-party components whose class is not linked instead of crashing at launch

Test Plan:

  • generate-artifacts-executor-test.js: the provider snapshots and the crawl case expect the name-to-class-name map. In Linux (WSL) the file's 52 tests and 24 snapshots pass; its suite-level fs.rmdirSync(…, {recursive: true}) cleanup fails under Node 26, on main too.
  • The generated RCTThirdPartyComponentsProvider.mm for two component libraries, compiled into a binary that links only one of their classes (clang++, Foundation, macOS):
    • main: NSInvalidArgumentException … attempt to insert nil object from objects[1]
    • this change: registered components: LinkedComponent
  • yarn flow: no errors; eslint and prettier on the changed files: clean.

…hing at launch

RCTThirdPartyComponentsProvider built its map with a dictionary literal of
NSClassFromString results, which throws when a component's library is not
linked into the target: an app extension or App Clip that leaves a library
out, or a macOS app whose dependencies include an iOS-only library. The
provider now maps component names to class names and registers the classes
the runtime has, as RCTModuleProviders does for module providers; a missing
component falls back to the unimplemented view if it is rendered.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 14, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 14, 2026

@cipolleschi cipolleschi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for fixing this.

@meta-codesync

meta-codesync Bot commented Oct 14, 2026

Copy link
Copy Markdown

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this in D125236957.

@meta-codesync meta-codesync Bot closed this in acc0cca Oct 14, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Oct 14, 2026
@meta-codesync

meta-codesync Bot commented Oct 14, 2026

Copy link
Copy Markdown

@cipolleschi merged this pull request in acc0cca.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants