-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Codegen] Exclude unlinked libs from codegen #47712
[Codegen] Exclude unlinked libs from codegen #47712
Conversation
Object.keys(dependency.platforms).forEach(platform => { | ||
if (dependency.platforms[platform] == null) { | ||
notLinkedPlatforms.push(platform); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously this was sufficient for module to be linked:
dependencies: {
'name': {
root: '/path/to/your/module',
},
},
With this change, projects with this config crash during pod install
since the platforms
field isn't present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for raising this other case. I believe that if there is just the path, it links for all the platforms, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cipolleschi currently it crashes when dependency.platforms
isn't specified because the above check is accessing keys on dependency.platforms
unconditionally
current workaround is to specify:
dependencies: {
'name': {
root: '/path/to/your/module',
platforms: { android: {}, ios: {} },
},
},
Summary:
There is a case where a library is added for a specific platform and unlinked for another platform, because perhaps we would like to use a different library.
The way in which this is implemented is through the
react-native.config.js
file, by setting a specific platform to null.Currently, Codegen ignore this information and generates the code for all the libraries it can find, including the unlinked ones. This can result in build failures because there are some functions prototype defined with no implementation.
This change takes thos libraries into account and it should fix: #47550.
Note
Codegen changed in 0.77, so we don't need to backport this to main
Changelog:
[General][Changed] - Stop generating code for unlinked libraries
Test Plan:
Tested in a new app created with 0.76.2, following the repro steps in #47550