Skip to content
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

Turbo Native Modules - Documentation ported from reactwg #4283

Merged
merged 26 commits into from
Oct 21, 2024

Conversation

blakef
Copy link
Contributor

@blakef blakef commented Oct 16, 2024

Turbo Native Modules Docs:

  • ✅ Intro
  • ✅ Android
  • ✅ iOS

Copy link

netlify bot commented Oct 16, 2024

Deploy Preview for react-native ready!

Name Link
🔨 Latest commit 0313c06
🔍 Latest deploy log https://app.netlify.com/sites/react-native/deploys/6716537e7fe90100084035f6
😎 Deploy Preview https://deploy-preview-4283--react-native.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@blakef blakef force-pushed the turbo-native-modules-update branch from e3ce0c8 to 62c925f Compare October 16, 2024 14:19
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job and thanks for working on this. I left several comments, I believe we need to streamline the content and the language as much as possible.

docs/appendix.md Outdated

## I. Terminology

- **Schema** - TypeScript or Flow code that describes the API for a Turbo Native Module or Fabric Native component. Used by **Codegen** to generate boilerplate code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱 We always use Spec for this definition, we never used Schema!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got mixed up. Just to confirm, the codegen pipeline is: SpecSchema → Platform Code (protocols, interfaces, etc...)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but the schema in json is an implementation details that the users should never see.

docs/appendix.md Outdated Show resolved Hide resolved
docs/appendix.md Outdated Show resolved Hide resolved
docs/fabric-native-modules-android.md Show resolved Hide resolved
docs/fabric-native-modules-ios.md Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
Comment on lines 206 to 242
<Tabs groupId="platforms" queryString defaultValue={constants.defaultPlatform}>
<TabItem value="android" label="Android">
Codegen is executed through the `generateCodegenArtifactsFromSchema` Gradle task:

```bash
cd android
./gradlew generateCodegenArtifactsFromSchema

BUILD SUCCESSFUL in 837ms
14 actionable tasks: 3 executed, 11 up-to-date
```

This is automatically run when you build your Android application.
</TabItem>
<TabItem value="ios" label="iOS">
Codegen is run as part of the script phases that's automatically added to the project generated by Cocoapods.

```bash
cd ios
bundle install
bundle exec pod install
bundle exec pod install

...
Framework build type is static library
[Codegen] Adding script_phases to ReactCodegen.
[Codegen] Generating ./build/generated/ios/ReactCodegen.podspec.json
[Codegen] Analyzing /Users/me/src/TurboModuleExample/package.json
[Codegen] Searching for codegen-enabled libraries in the app.
[Codegen] Found TurboModuleExample
[Codegen] Searching for codegen-enabled libraries in the project dependencies.
[Codegen] Found react-native
...
```

</TabItem>
</Tabs>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed from here. Those information are already in the codegen guide and we don't want that for an app developer to run codegen separatedly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have to have these included, otherwise the guide is incomplete. If I try open these projects up in their respective editors:

Xcode

Can't until the xcworspace has been generated.

Android Studio

Before

CleanShot 2024-10-17 at 16 18 11@2x

After

CleanShot 2024-10-17 at 16 19 56@2x

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pod install needs to be executed for sure, but I would remove the lines that refers to codegen, that's an implementation detail for the user.

I never used Android studio, but I can see the problem. The thing is that we would like for codegen to be transparent... If we ask the users to execute it manually, that's not transparent anymore. :(

cc. @cortinico what do you think about this?

docs/turbo-native-modules.md Show resolved Hide resolved
@blakef blakef changed the title turbo native modules update Turbo Native Modules - Documentation ported from reactwg Oct 17, 2024
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, left minor nits and some formatting.

docs/native-platforms.md Outdated Show resolved Hide resolved
docs/native-platforms.md Outdated Show resolved Hide resolved
docs/the-new-architecture/using-codegen.md Show resolved Hide resolved
docs/turbo-native-modules-android.md Outdated Show resolved Hide resolved
docs/turbo-native-modules-android.md Outdated Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
1. **define a typed JavaScript specification** using one of the most popular JavaScript type annotation languages: Flow or TypeScript;
2. **configure your dependency management system to run Codegen**, which converts the specification into native language interfaces;
3. **write you application code** using your specification
4. **write your native platform code using the generated interfaces** to write and hook your native code into the React Native runtime environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
4. **write your native platform code using the generated interfaces** to write and hook your native code into the React Native runtime environment
4. **write your native platform code using the generated interfaces** to write and hook your native code into the React Native runtime environment.

docs/turbo-native-modules.md Outdated Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
Copy link
Contributor Author

@blakef blakef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cipolleschi added all your feedback. I think we're good to go.

docs/fabric-native-modules-ios.md Show resolved Hide resolved
docs/the-new-architecture/using-codegen.md Show resolved Hide resolved
docs/native-platforms.md Outdated Show resolved Hide resolved
docs/turbo-native-modules.md Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
docs/turbo-native-modules.md Outdated Show resolved Hide resolved
website/sidebars.json Outdated Show resolved Hide resolved
@cipolleschi cipolleschi merged commit 1de360f into main Oct 21, 2024
4 checks passed
@cipolleschi cipolleschi deleted the turbo-native-modules-update branch October 21, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants