Skip to content

Exclude selectively disabled libraries from codegen generation #51078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

ismarbesic
Copy link

Summary:

Selectively disabling autolinking of a native dependency with components registered in the codegen configuration in react-native.config.js causes builds to crash upon launch on iOS. This is because the generated RCTThirdPartyComponentsProvider.mm file contains references to the excluded library using NSClassFromString causing the returned NSDictionary from +[RCTThirdPartyComponentsProvider thirdPartyFabricComponents] to be populated with nil values and therefore crashing the app. This has been confirmed in 0.78.2 and 0.79.2 but probably exists in 0.77.x as well.

The issue has been further described in #51077.

Changelog:

[IOS][FIXED] - Skip codegen for selectively disabled libraries in react-native.config.js

Test Plan:

  1. Install a library that has the componentProvider field set in the codegen config (see reproducer) and install the iOS pods.
  2. Build the app.
  3. App should run successfully without any crashes.

@facebook-github-bot
Copy link
Contributor

Hi @ismarbesic!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@ismarbesic ismarbesic changed the title chore: exclude selectively disabled libraries from codegen generation Exclude selectively disabled libraries from codegen generation May 2, 2025
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels May 2, 2025
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

The code looks good to me. Thanks for fixing this issue!

@facebook-github-bot
Copy link
Contributor

@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 8, 2025
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in be8595b.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @ismarbesic in be8595b

When will my fix make it into a release? | How to file a pick request?

react-native-bot pushed a commit that referenced this pull request May 12, 2025
Summary:
Selectively disabling autolinking of a native dependency with components registered in the codegen configuration in react-native.config.js causes builds to crash upon launch on iOS. This is because the generated `RCTThirdPartyComponentsProvider.mm` file contains references to the excluded library using `NSClassFromString` causing the returned NSDictionary from `+[RCTThirdPartyComponentsProvider thirdPartyFabricComponents]` to be populated with nil values and therefore crashing the app. This has been confirmed in 0.78.2 and 0.79.2 but probably exists in 0.77.x as well.

The issue has been further described in #51077.

## Changelog:

[IOS][FIXED] - Skip codegen for selectively disabled libraries in react-native.config.js

Pull Request resolved: #51078

Test Plan:
1. Install a library that has the componentProvider field set in the codegen config (see reproducer) and install the iOS pods.
2. Build the app.
3. App should run successfully without any crashes.

Reviewed By: cortinico

Differential Revision: D74248371

Pulled By: cipolleschi

fbshipit-source-id: 1ff7b477ed3d94ca45616ae243d3d2d30bd897db
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @ismarbesic in 7ce8f12

When will my fix make it into a release? | How to file a pick request?

facebook-github-bot pushed a commit that referenced this pull request Jun 6, 2025
…ion (#51838)

Summary:
PR #51078 Implemented finding disabled libraries but the code (below) didn't actually filter any libraries out because destructured name is `undefined`. This pr adds the name to codegenEnabledLibraries so filtering would work.

```js
const libraries = codegenEnabledLibraries.filter(
  ({name}) => !disabledLibraries.includes(name),
);
```

## Changelog:

[IOS] [FIXED] - Skip codegen for selectively disabled libraries in react-native.config.js

Pull Request resolved: #51838

Test Plan:
1. Install a library that has the componentProvider field set in the codegen config (for example: react-native-safe-area-context and react-native-screens or see [reproducer](https://github.com/aattola/rn-codegen-exclude))
2. Exclude library with react-native.config.js
3. install pods / run codegen
4. Check that codegen actually excluded the specified dependencies from: `ios/build/generated/ios/RCTThirdPartyComponentsProvider.mm`

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76044622

Pulled By: cipolleschi

fbshipit-source-id: 9e70c2a263c750edb1ea95305c9e5e178e2ce8d8
react-native-bot pushed a commit that referenced this pull request Jun 9, 2025
…ion (#51838)

Summary:
PR #51078 Implemented finding disabled libraries but the code (below) didn't actually filter any libraries out because destructured name is `undefined`. This pr adds the name to codegenEnabledLibraries so filtering would work.

```js
const libraries = codegenEnabledLibraries.filter(
  ({name}) => !disabledLibraries.includes(name),
);
```

## Changelog:

[IOS] [FIXED] - Skip codegen for selectively disabled libraries in react-native.config.js

Pull Request resolved: #51838

Test Plan:
1. Install a library that has the componentProvider field set in the codegen config (for example: react-native-safe-area-context and react-native-screens or see [reproducer](https://github.com/aattola/rn-codegen-exclude))
2. Exclude library with react-native.config.js
3. install pods / run codegen
4. Check that codegen actually excluded the specified dependencies from: `ios/build/generated/ios/RCTThirdPartyComponentsProvider.mm`

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76044622

Pulled By: cipolleschi

fbshipit-source-id: 9e70c2a263c750edb1ea95305c9e5e178e2ce8d8
fabriziocucci added a commit that referenced this pull request Jul 9, 2025
Summary:
Selectively disabling autolinking of a native dependency with components registered in the codegen configuration in react-native.config.js causes builds to crash upon launch on iOS. This is because the generated `RCTThirdPartyComponentsProvider.mm` file contains references to the excluded library using `NSClassFromString` causing the returned NSDictionary from `+[RCTThirdPartyComponentsProvider thirdPartyFabricComponents]` to be populated with nil values and therefore crashing the app. This has been confirmed in 0.78.2 and 0.79.2 but probably exists in 0.77.x as well.

The issue has been further described in #51077.

[IOS][FIXED] - Skip codegen for selectively disabled libraries in react-native.config.js

Pull Request resolved: #51078

Test Plan:
1. Install a library that has the componentProvider field set in the codegen config (see reproducer) and install the iOS pods.
2. Build the app.
3. App should run successfully without any crashes.

Reviewed By: cortinico

Differential Revision: D74248371

Pulled By: cipolleschi

fbshipit-source-id: 1ff7b477ed3d94ca45616ae243d3d2d30bd897db
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.

4 participants