| Crates.io | frb_plugin_tool_ohos |
| lib.rs | frb_plugin_tool_ohos |
| version | 0.4.0 |
| created_at | 2025-11-10 07:35:04.559797+00 |
| updated_at | 2025-11-18 03:32:36.961766+00 |
| description | dart rust frb 快速生成项目脚本 |
| homepage | https://github.com/mdddj/frb_plugin_tool |
| repository | https://github.com/mdddj/frb_plugin_tool |
| max_upload_size | |
| id | 1924874 |
| size | 107,503 |
快速生成 Flutter Rust Bridge (FRB) 插件项目的命令行工具,支持多平台包括 HarmonyOS Next (鸿蒙系统)。
✨ 全平台支持
✨ 自动化配置
注意: 因为要从 GitHub 拉取相关依赖,网络环境需要能访问 GitHub,否则会失败
cargo install frb_plugin_tool_ohos
frb_plugin_tool_ohos --help
frb_plugin_tool_ohos 提供三个主要命令:
create - 创建新插件项目创建一个新的 Flutter Rust Bridge 插件项目,支持所有平台。
frb_plugin_tool_ohos create --name <插件名称> --fvm-flutter-version <Flutter版本>
--name / -n: 插件名称(必需)
my_plugin, hello_world--fvm-flutter-version / -f: FVM Flutter 版本(必需)
custom_3.27-oh# 创建名为 my_plugin 的插件
frb_plugin_tool_ohos create -n my_plugin -f custom_3.27-oh
该命令会自动:
OHOS_SETUP.md 配置指南replace - 替换占位符遍历指定目录,将文件中的 REPLACE_PLUGIN_NAME 占位符替换为实际的插件名称。
frb_plugin_tool_ohos replace --dir <目录路径> --name <插件名称>
--dir / -d: 目标目录路径(必需)
./my_project/ohos--name / -n: 用于替换的插件名称(必需)
my_plugin# 替换 ohos 目录中的占位符
frb_plugin_tool_ohos replace -d ./my_plugin/ohos -n my_plugin
REPLACE_PLUGIN_NAME 出现presetup - 配置 OHOS 开发环境自动配置 HarmonyOS Next 开发环境,包括创建编译脚本和配置 Cargo。
frb_plugin_tool_ohos presetup \
--script-path <脚本目录> \
--openharmony-path <SDK路径> \
[--force]
--script-path / -s: 脚本存放目录(必需)
/Users/username/.ohos/script--openharmony-path / -o: OpenHarmony SDK 路径(必需)
/Users/username/hmos/command-line-tools/sdk/default/openharmony--force / -f: 强制替换现有配置(可选)
false普通模式(检测已有配置):
frb_plugin_tool_ohos presetup \
-s ~/.ohos/script \
-o ~/hmos/command-line-tools/sdk/default/openharmony
强制模式(覆盖现有配置):
frb_plugin_tool_ohos presetup \
-s ~/.ohos/script \
-o ~/hmos/command-line-tools/sdk/default/openharmony \
--force
该命令会自动:
创建编译脚本(在 script_path 目录):
aarch64-unknown-linux-ohos-clang.shaarch64-unknown-linux-ohos-clang++.shx86_64-unknown-linux-ohos-clang.shx86_64-unknown-linux-ohos-clang++.sh配置 Cargo(~/.cargo/config.toml):
aarch64-unknown-linux-ohos target 配置x86_64-unknown-linux-ohos target 配置智能处理:
frb_plugin_tool_ohos add-support
需要在插件项目的根目录下执行 (要读取 pubspec.yaml下面的 name属性)
# 首次配置
frb_plugin_tool_ohos presetup \
-s ~/.ohos/script \
-o ~/hmos/command-line-tools/sdk/default/openharmony
# 如果需要更新配置
frb_plugin_tool_ohos presetup \
-s ~/.ohos/script \
-o ~/hmos/command-line-tools/sdk/default/openharmony \
--force
frb_plugin_tool_ohos create -n my_awesome_plugin -f custom_3.27-oh
cd my_awesome_plugin
# 查看生成的鸿蒙配置指南
cat OHOS_SETUP.md
# 构建项目
flutter build ohos
Rust 工具链
Flutter SDK
Git
FVM (可选,用于 Flutter 版本管理)
HarmonyOS SDK (用于鸿蒙平台开发)
QQ 群: 706438100