Docs: Getting Started with the New Architecture #8
Replies: 26 comments 99 replies
-
I may be wrong but most of the examples are written in flow, could be great to have a vanilla js alternative available. |
Beta Was this translation helpful? Give feedback.
-
Worked through the TurboModules guide this weekend, here is a bit of my feedback. I am also happy to create PR with suggested changes if that is helpful.
Planning on moving on to the Fabric tutorial later this week. |
Beta Was this translation helpful? Give feedback.
-
I think it'd be helpful if the docs mentioned why |
Beta Was this translation helpful? Give feedback.
-
I just want to be clear on this. we cant use swift files with turbo modules correct? |
Beta Was this translation helpful? Give feedback.
-
@griffinshuth Nico is on PTO until January! 😉 But I'll be available almost for the whole holiday period, so I can help with any iOS related issues.
I saw these errors, but even if Xcode output them, the build is successful and the app can execute properly. I still have to figure out what's the best path to avoid them, but we are at least in a setup where users can develop and test their code.
The reason why you need to create the app with version 0.71 is because the +folly_version = '2021.07.22.00'
+folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
Pod::Spec.new do |s|
s.name = "calculator"
s.version = package["version"]
# ...
- install_modules_dependencies(s)
+ # This guard prevent to install the dependencies when we run `pod install` in the old architecture.
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
+ s.pod_target_xcconfig = {
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
+ }
+
+ s.dependency "React-Codegen"
+ s.dependency "RCT-Folly", folly_version
+ s.dependency "RCTRequired"
+ s.dependency "RCTTypeSafety"
+ s.dependency "ReactCommon/turbomodule/core"
+ end Note: yesterday, we release RC5 for 0.71. We plan to release RN 0.71 stable early in January.
This change is optional, it should work also with the previous setup. In 0.71, we simplified a lot of machinery for the New Architecture, in both Android and iOS. For iOS specifically, we encapsulated a lot of logic in the
This should actually still work. Could you please share which error it is reporting?
Yes, definitely. The code will look like this: @interface AppDelegate : RCTAppDelegate <RNAppAuthAuthorizationFlowManager>
@property(nonatomic, weak)id<RNAppAuthAuthorizationFlowManagerDelegate>authorizationFlowManagerDelegate;
@end
I hope these suggestions can help you getting through the problems you are having. Let me know if there are any updates! |
Beta Was this translation helpful? Give feedback.
-
I think there are some mistakes in the documentation:
This part is not clear:
Its not clear who these files belong to and where they are located. I assume these are files owned by the project (files we wrote ourselves), so in most cases I guess there are no such files? If that's the case I think you should state it clearly. I think that would be nice to have something similar to the RnDiffApp to help people check how the folder structure should look like (that would also prevent having path issues like the one I mentioned first). Talking about this, I noticed the
While the RnDiffApp contains:
I have none of these two files on my machine so I can't really say which import is correct, what is the procedure to get this file? |
Beta Was this translation helpful? Give feedback.
-
Hi @cglacet, thanks for pointing out these problems. I prepared a PR here: facebook/react-native-website#3559
You are right, the right folder is
These files are available ONLY from version 0.71 onwards of react native. |
Beta Was this translation helpful? Give feedback.
-
I was reading about Turbo Native Modules and I noticed in the IOS section(https://reactnative.dev/docs/the-new-architecture/pillars-turbomodules#write-the-native-ios-code) that the |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Hi everyone.
|
Beta Was this translation helpful? Give feedback.
-
Hi everyone. (1) Should I define Turbo modules separately from the (android) app ? (2) How can I get a data or call a method of the android app module from React Native JS layer? please help.. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Hello React Native New Architecture team! Thanks so much providing this discussion space. I'm working on rolling out a new React Native app which uses turbo modules, following the docs here, and I have not been able to get it working. I've prepared a repro example and I am hoping you can take a look and let me know what I might be doing wrong here. There are a lot of details in the The setup:
When running BUILD FAILED in 31s
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/Users/masha/Code/turbo-module-cannot-find-symbol-repoducer/AwesomeProject/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:15: error: cannot find symbol
import com.rtngreeter.GreeterPackage;
^
symbol: class GreeterPackage
location: package com.rtngreeter
/Users/masha/Code/turbo-module-cannot-find-symbol-repoducer/AwesomeProject/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:61: error: cannot find symbol
new GreeterPackage()
^
symbol: class GreeterPackage
location: class PackageList
2 errors
FAILURE: Build completed with 2 failures. |
Beta Was this translation helpful? Give feedback.
-
Hello! I'm working to migrating react-native-vlc-media-player to New Architecture Fabric. It's a streaming player which requires a lot of callbacks and player state. The depreciated package uses RCTEventEmitter to communicate player state to JS. I'm attempting to replicate this in NA but I'm not finding documentation on how to implement EventEmitter in Fabric only Turbo. I've read that RCTEventEmitter is depreciated in Fabric NA and there's two new classes RCTModernEventEmitter and ReactEventEmitter but when I attempt to implement them the app crashes with no errors. When I tried using RCTEventEmitter I get this error
I'm also attempting to add the event callbacks to the NativeProps but it doesn't appear that a Function type is support in NA only string, number, boolean and null. I'm wondering if EventEmitters are possible in Fabric NA, they are shown in the uimanager package so I assumed so. If not then I'm wondering if I have to build this into Turbo and link Native code between Turbo and Fabric. Any help would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
-
Hello again @cortinico ! Thanks again for all your hard work on the New Architecture and being so responsive in this forum. I have another question for you, this time a bit more general. We are working on creating a new architecture turbo module that leverages a Swift library as a dependency, specifically https://github.com/dawnwallet/dawn-key-management. This library only has an SPM definition, and we know React Native is incompatible with SPM. So we're creating a Cocoapod of this library, writing our own We've been having trouble defining the structure of the library in the So we're wondering, do turbo module cocoapod dependencies need to be built as a specific one of the above? And do you have any resources or advice about how to create Swift cocoapods dependencies and integrate them with turbo modules? Thanks again for taking the time! |
Beta Was this translation helpful? Give feedback.
-
Hello there and thank you in advance for the support! I'm uncertain whether I'm reporting a genuine problem or something I'm struggling to understand. I am creating a backwards-compatible Fabric Component. It's my first time implementing any native component, so that's my handicap coming into this. I followed the example Fabric component docs, got that example running on a clean project with the new architecture, and then today worked through the Fabric Legacy docs. I followed the documentation as exactly as possible. The only thing I've changed is the name of the module to fit what I'm building. My legacy-enabled fabric module is compiling for both old-architecture and new-architecture android and ios apps. My module is working and I'm able to update the text on ios and android apps running the new architecture. The module is also fully functional in android apps running the old architecture. The problem I'm experiencing is that when I try to compile my module for an old architecture ios app, I get the following error:
I am able to get the app to compile and run if I remove In my reading of the ios I've also tried working through the Backward compatibility community git repo. It was different enough from the on-site documentation, though, that I decided to post here as well. For context, here is my RTNMapsGLManager.mm code:
I realize all code in the documentation has been tested, so I'm sorry if this issue is related to a mistake I've made. |
Beta Was this translation helpful? Give feedback.
-
Hey! Great work on the documentation, reading the introduction to the new architecture makes it all very easy. Looking at the..., I got confused with one line in particular and have read it a couple of times to understand. The following sentence explains steps required to create either a turbo module or a fabric component ("the pillars").
I am not a native speaker, I might be just misunderstanding things - in which case, please consider this invalid. The new architecture has three pillars, including "codegen", so referenced sentence implies you can create "codegen" by following these steps. I think the original intent was to refer to earlier section on that page:
I think a quick solution would be to update the wording to something as follows:
< line break >
< line break >
|
Beta Was this translation helpful? Give feedback.
-
I'm generating a Turbo Module with Example (iOS):
I managed to bridge them only once (single-source-of-truth, C++) with a Native Module + JSI and exported them to |
Beta Was this translation helpful? Give feedback.
-
I followed Fabric Native Components doc, it worked. Thanks |
Beta Was this translation helpful? Give feedback.
-
how create turboModule in main app folder,but like the demo as a library in node_modules folder, in app folder,add codegenConfig and gegerate codegen files success,create turboModule and TurboReactPackage, and to PackageListbut , but in App.tsx can not import the TurboModule. can introduce how to add in app ,but not extranal folder by yarn add XXX ? structure like this in android |
Beta Was this translation helpful? Give feedback.
-
hi! I'm looking at RNTP's interop layer compatibility, and there is an issue where the module's hooks using event listeners (with a NOBRIDGE log tag?) are not firing, but listeners registered via AppRegistry.registerHeadlessTask (without the NOBRIDGE log tag) are. Would anyone share insight on emitting events? Thank you very much in advance the way RNTP emits events: |
Beta Was this translation helpful? Give feedback.
-
Hi. Thank you for the docs. I've just created an example of a Turbo Module in iOS following this tutorial. I believe there might be some very minor typos in there preventing it from running as it currently is. While, perhaps, immediately obvious and easily spotted to most, they may come as show stoppers to some users who are completely new to the subject.
Again, these are small and obvious for seasoned developers, but they may save some time / frustrations for people just starting with the subject. |
Beta Was this translation helpful? Give feedback.
-
I'm just getting started with React Native as we need to write an RN client library for our platform. I'm finding that you all have done a great job trying to make this as intuitive as possible, so kudos here. I think you all need to invest heavily in guidance on marshallng data between JS and C++ (and through Java for non-pure-C++ modules). Coming from the C# ecosystem where Microsoft has done an incredible job with P/Invoke, I think you all can emulate a lot of their success. Right now I'm stuck trying to figure out the best way to marshal opaque types (raw pointers) and enumerations. There doesn't seem to be much in the way of sample code or written guidance in the docs, so I'm likely gonna end up casting back and forth between |
Beta Was this translation helpful? Give feedback.
-
are these docs still valid? I followed the steps, but codegen does not generate the file my schema.json {
"modules": {}
} Android.mk does not get generated. I need to build my library using Java, not kotlin. |
Beta Was this translation helpful? Give feedback.
-
How to avoid running codegen and generating code in case of old architecture? I created library using create-react-native-library. But when I run library on old architecture project, codegen still creates the code and hence build fails with this issue "ReactCommon/TurboModule.h' file not found" from RNSpecJSI file. I have already followed all steps listed here https://github.com/reactwg/react-native-new-architecture/blob/main/docs/backwards-compat-turbo-modules.md. |
Beta Was this translation helpful? Give feedback.
-
I use Windows for my development environment. I was trying the RTNCenteredText instructions to create/learn Fabric components and I hit this build error:
I use the below workaround in the app's build.gradle file due to the "long path" issue in Windows:
I removed the Though the build goes through fine, the app fails with below error:
The file is found in the I created a new project by repeating all the steps (without the hyphens in the name) and still end up with same error. I am not sure if this is an issue but thought will bring this to your notice. Also, a suggestion on the documentation. Since there are two android folders (one within the React Native project and the other within the Native component), can some sort of distinction be made between the two so it is less confusing for a newbie like me. Thank you otherwise for the excellent documentation. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
This thread is to collect feedback on the section of the website called: Getting Started with the New Architecture - https://reactnative.dev/docs/next/new-architecture-intro
If you happen to go through the guide, feel free to report:
General feedback is also more than welcome.
Beta Was this translation helpful? Give feedback.
All reactions