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
[FEAT][TNA] Fabric Component - Add Native Code (iOS) #3148
[FEAT][TNA] Fabric Component - Add Native Code (iOS) #3148
Conversation
❌ Deploy Preview for react-native failed.
|
7ee938b
to
e8af588
Compare
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.
LGTM 👍
3b8874f
to
2b820e5
Compare
e8af588
to
c2de0d4
Compare
cd .. | ||
node MyApp/node_modules/react-native/scripts/generate-artifacts.js \ | ||
--path MyApp/ \ | ||
--outputPath RTNCenteredTextFlow/generated/ |
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.
I am not sure I understand why we add the component module to the app, but then have codegen output the generated code to the component module?
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.
To run the CodeGen, we need a React Native app (which can access the React Native code). A module alone does not have that dependency, therefore we need to add the module to the app.
Once that is done, we can invoke the CodeGen manually to see what it will outputs, so that we can use the right filenames and types.
By invoking the codegen manually, we need to define an output folder and I thought it was easier to use the module folder as root.
As specified in the caution block above, the code generated manually should not be committed to the code versioning system and will be discarded. React Native relies on the code generated automatically when building the app.
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.
Cool, that makes sense -- it might be good to briefly explain the intention here, the reader may wonder (as I did) if this process is necessary in the normal course of development
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.
I added a couple of paragraphs before the iOS
section to describe that. Let me know what do you think!
##### Write the Native iOS Code | ||
|
||
Now that we can see the iOS code we need, it's time to write the Native code for our Fabric Component. | ||
We need to create three files: |
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.
We should say specifically where: in the top level of the ios
directory?
I'm also wondering something that I think would be good to explicitly state: is the reader intended to be using XCode to work on this in the RTNCenteredText/ios
directory and be able to use the imports? I'm not sure what the intended way is to do that, particularly when the generated code is in another directory that's a sibling with ios
/android
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.
We should say specifically where: in the top level of the ios directory?
Good point. It will be in the centered-text/ios
folder.
I'm also wondering something that I think would be good to explicitly state: is the reader intended to be using XCode to work on this in the RTNCenteredText/ios directory and be able to use the imports? I'm not sure what the intended way is to do that, particularly when the generated code is in another directory that's a sibling with ios/android
For this sample, I didn't used Xcode at all. The problem with Xcode is that we have to tell them to create an .xcodeproject
file (for a static library) otherwise Xcode won't be able to work with those properly. In any case, they won't be able to build the module from Xcode because they miss the React Native dependencies.
So, at the end of the day, I don't think we should suggest them to use Xcode... It could create more confusion with the errors it will display.
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.
What's your flow for writing this code? Do you use any other tooling to help make sure it's correct?
I think it's important for a guide like this to demonstrate what the regular development flow should be like, or people are likely to feel stuck after they aren't just copying files
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.
Yeah, you are completely right, but that's a pain point, unfortunately. Currently, there is no easy way to do that.
The tool I use is VisualStudio code and then I have a test app that I use as test bed. Basically, I yarn add
the module, install the dependencies and I try to build it. If there are errors, I fix them in the Development Pods
folder until they are ok and then I have to copy-and-paste the files back in the RTNCenteredText
folder.
That's far from being ideal and I think it is a little bit too convoluted to explain it to the users... what do you think?
2b820e5
to
25ab1e5
Compare
c2de0d4
to
b54eeb4
Compare
6e41e16
to
d48e335
Compare
b54eeb4
to
6403af3
Compare
6403af3
to
b2e7bbf
Compare
* feat: add fabric component to app - ios * [FEAT][TNA] Fabric Component - Add Native Code (Android) (#3152) * feat: add native code for android * [FEAT][TNA] Fabric Component - Add Component to App (Android) (#3153) * feat: Add fabric component to app - Android * feat: improve structure and consistency (#3154)
* feat: add section on configuration * [FEAT][TNA] Fabric Component - Add Native Code (iOS) (#3148) * feat: Add native code for iOS * [FEAT][TNA] Fabric Component - Add Component to App (iOS) (#3149) * feat: add fabric component to app - ios * [FEAT][TNA] Fabric Component - Add Native Code (Android) (#3152) * feat: add native code for android * [FEAT][TNA] Fabric Component - Add Component to App (Android) (#3153) * feat: Add fabric component to app - Android * feat: improve structure and consistency (#3154)
…Specs (#3133) * [Feat] Add JavaScript for Fabric Components * [FEAT][TNA] Fabric Component - Add Configuration Files (#3136) * feat: add section on configuration * [FEAT][TNA] Fabric Component - Add Native Code (iOS) (#3148) * feat: Add native code for iOS * [FEAT][TNA] Fabric Component - Add Component to App (iOS) (#3149) * feat: add fabric component to app - ios * [FEAT][TNA] Fabric Component - Add Native Code (Android) (#3152) * feat: add native code for android * [FEAT][TNA] Fabric Component - Add Component to App (Android) (#3153) * feat: Add fabric component to app - Android * feat: improve structure and consistency (#3154)
This PR adds the Native code for a Fabric Component.
It explains how to use the CodeGen manually, to check what RN will generate, and it proceed by creating the native code.
This PR only contains the iOS part. The Android part will come in a different PR.