mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ebb2b9c3fc
Summary: ### The problem 1. We have a library that's supported on iOS but doesn't have support for visionOS. 2. We run pod install 3. Codegen runs and generates Code for this library and tries to reference library class in `RCTThirdPartyFabricComponentsProvider` 4. Example: ```objc Class<RCTComponentViewProtocol> RNCSafeAreaProviderCls(void) __attribute__((used)); // 0 ``` This is an issue because the library files are not linked for visionOS platform (because code is linked only for iOS due to pod supporting only iOS). ### Solution Make codegen take Apple OOT platforms into account by adding compiler macros if the given platform doesn't explicitly support this platform in the native package's podspec file. Example generated output for library supporting only `ios` and `visionos` in podspec:  I used compiler conditionals because not every platform works the same, and if in the future let's say react-native-visionos were merged upstream compiler conditionals would still work. Also tvOS uses Xcode targets to differentiate which platform it builds so conditionally adding things to the generated file wouldn't work. ## Changelog: [IOS] [ADDED] - make codegen take OOT Apple platforms into account Pull Request resolved: https://github.com/facebook/react-native/pull/42047 Test Plan: 1. Generate a sample app with a template 5. Add third-party library (In my case it was https://github.com/callstack/react-native-slider) 6. Check if generated codegen code includes compiler macros Reviewed By: cipolleschi Differential Revision: D52656076 Pulled By: dmytrorykun fbshipit-source-id: c827f358997c70a3c49f80c55915c28bdab9b97f
@react-native/codegen
Installation
yarn add --dev @react-native/codegen
Note: We're using yarn to install deps. Feel free to change commands to use npm 3+ and npx if you like
Testing
To run the tests in this package, run the following commands from the React Native root folder:
yarnto install the dependencies. You just need to run this onceyarn jest packages/react-native-codegen.