callstack / callstack/react-native-builder-bob

The C++ Turbo Module template uses a Kotlin implementation on Android

未关闭
#829 20 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
JavaScript
星标
3.2k
派生
228
平均合并
7 天 12 小时
30 天内合并 PR
3

描述

### Description

I'm not sure if I'm missing something obvious but when creating the library template for a Turbo Module using C++ for Android & iOS there is a default example implementing a `multiply` function. However, on Android the implementation for this function is in Kotlin and it doesn't use the shared C++ library.

When the JS code calls `multiply` it comes into the code [here](https://github.com/callstack/react-native-builder-bob/blob/main/packages/create-react-native-library/templates/kotlin-library-new/android/src/main/java/com/%7B%25-%20project.package_dir%20%25%7D/%7B%25-%20project.name%20%25%7DModule.kt#L17).

Is there any reason why the `OnLoad.cpp` file isn't used to register the turbo module in this case as described here: [pure-cxx-modules#android](https://reactnative.dev/docs/the-new-architecture/pure-cxx-modules#android)

### Packages

- [x] create-react-native-library
- [ ] react-native-builder-bob

### Selected options

1. `npx create-react-native-library cppLibraryTest`
2. ? What is the name of the npm package? › cpp-lib-test
3. ? What type of library do you want to develop? › Turbo Module
4. ? Which languages do you want to use? › C++ for Android & iOS

### Link to repro

N/A

### Environment

```
System:
OS: macOS 15.0.1
CPU: (11) arm64 Apple M3 Pro
Memory: 90.06 MB / 18.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 23.7.0
path: /opt/homebrew/bin/node
Yarn:
version: 3.6.1
path: /opt/homebrew/bin/yarn
npm:
version: 11.2.0
path: /opt/homebrew/bin/npm
Watchman:
version: 2025.02.17.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /opt/homebrew/opt/ruby/bin/pod
```

贡献指南

打开贡献指南

调研方向

首先比较 `kotlin-library-new` 模板中生成的 Android 文件 `OnLoad.cpp` 和 `android/src/main/java/...Module.kt`,然后阅读链接的 React Native 纯 C++ Android 指南。确认生成的 `multiply` 调用是如何注册的,并确定模板需要进行的更改,以便 Android 实现使用共享的 C++ 模块。

由索引模型根据 Issue 内容生成。

评估

技术栈
cpp, kotlin, react-native
领域
mobile, tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。