Enabling in iOS Library
This documentation is still experimental and details are subject to changes as we iterate. Feel free to share your feedback on the discussion inside the working group for this page.
Moreover, it contains several manual steps. Please note that this won't be representative of the final developer experience once the New Architecture is stable. We're working on tools, templates and libraries to help you get started fast on the New Architecture, without having to go through the whole setup.
1. Updating your Podspec for the New Architecture
The New Architecture makes use of CocoaPods.
Add Folly and Other Dependencies
The New Architecture requires some specific dependencies to work properly. You can set up your podspec to automatically install the required dependencies by modifying the
.podspec file. In your
Pod::Spec.new block, add the following line:
Pod::Spec.new do |s|
At this link, you can find the documentation of the
If you need to explicitly know which
folly_flags React Native is using, you can query them using the
2. Extend or Implement the Code-generated Native Interfaces
While this generated native interface code will not ship as part of your library, you do need to make sure your Objective-C or Java code conforms to the protocols provided by these native interface files. You can use the Codegen script to generate your library’s native interface code in order to use it as a reference.
node node_modules/react-native/scripts/generate-codegen-artifacts.js \
--path <your app>/ \
--outputPath <an/output/path> \
This command will generate the boilerplate code required by iOS in the output path provided as a parameter.
The files that are output by the script should not be committed, but you’ll need to refer to them to determine what changes you need to make to your native modules in order for them to provide an implementation for each generated
@protocol / native interface.
Conform to the protocols provided by the native interface code
Following the example set forth in the previous section, your library might import
MyAwesomeSpecs.h, extend the relevant native interface, and implement the necessary methods for this interface:
@interface MyAwesomeModule () <StringGetterSpec>
// Implement this method
- (std::shared_ptr<TurboModule>)getTurboModule:(const ObjCTurboModule::InitParams &)params
For an existing native module, you will likely already have one or more instances of
RCT_EXPORT_METHOD. To migrate to the New Architecture, you’ll need to make sure the method signature uses the structs provided by the Codegen output.