Repository navigation
fix(codegen): skip third-party components whose class is not linked - #3128
Draft
YevheniiKotyrlo wants to merge 1 commit into
Draft
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
Cherry-pick of react#59067 (acc0cca), without its test file change: this suite has no generateRCTThirdPartyComponents case. The generated RCTThirdPartyComponentsProvider built its map from a dictionary literal of NSClassFromString values, so a component whose library the target does not link inserted nil and threw at launch. react-native-macos runs codegen with -t ios, so a library's iOS components reach a macOS target's provider whether or not the library ships macOS classes. The provider now maps each component name to its class name and skips a class that is not found, as RCTModuleProvidersMM.template does for modules.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Cherry-pick of react#59067 (acc0cca), without its test-file change, which edits a
generate-artifacts-executor-test.jscase this branch does not have.The generated
RCTThirdPartyComponentsProvider.mmbuilds its map from a dictionary literal ofNSClassFromStringresults, so when a component's class is not linked into the app, the literal gets nil and the app aborts at launch:On macOS this happens whenever a dependency's components have no macOS classes: codegen runs with
-t ios, so their entries reach the macOS app's provider, andplatforms: { macos: null }inreact-native.config.jsdoes not keep them out, since the disabled-library filter reads theiosentry. react-native-skia's macOS example aborts at launch this way on 0.81. The provider now maps component names to class names and registers only the classes the runtime has, asRCTModuleProvidersMM.templatedoes for modules.0.81-stable and 0.83-stable carry the same template, and this commit cherry-picks onto both without conflicts.
Test Plan:
generate-artifacts-executor-test.js: its twoRCTThirdPartyComponentsProvider.mmsnapshots expect the new map. Withmain's template and generator they fail; with this change the file's 39 tests pass, here and on 0.83-stable with the commit cherry-picked.main:NSInvalidArgumentException … attempt to insert nil object from objects[1]registered components: LinkedComponentyarn test-ci,yarn flow-check,yarn lint,yarn format-checkandyarn constraintspass.Not run here: the macOS core prebuild.