HarmonyOS鸿蒙Next中OHPM私库依赖了另一个私库,这个被依赖的私库文件路径在哪
HarmonyOS鸿蒙Next中OHPM私库依赖了另一个私库,这个被依赖的私库文件路径在哪
我有这么个需求,我的一个私库@newlink/rncore依赖了另一个库[@rnoh/react_native_openharmony](https://example.com/@rnoh/react_native_openharmony),A库的package.json
文件如下
{
"name": "@newlink/rncore",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "Index.ets",
"author": "huangfuyudong",
"license": "Apache-2.0",
"dependencies": {
"[@rnoh](/user/rnoh)/react-native-openharmony": "0.72.54-0.0.4",
"@ohos/crypto-js": "2.0.2",
},
}
现在项目中我依赖了库@newlink/rncore,这时候我的项目的entry模块的CMakeList.txt想要访问库[@rnoh/react_native_openharmony](https://example.com/@rnoh/react_native_openharmony)中的文件,这个文件路径该怎么写,我在entry的oh_module中没有找到[@rnoh/react_native_openharmony](https://example.com/@rnoh/react_native_openharmony)这个文件夹,但是在根目录的oh_module中找到了,但是文件路径有版本号啥,正确的做法应该是怎么样呢
根目录中在[@rnoh](/user/rnoh)+react-native-openharmony@0.72.54-0.0.4/oh_modules/[@rnoh](/user/rnoh)/react-native-openharmony
// 这个RNOH_CPP_DIR该怎么定位到[[@rnoh](/user/rnoh)/react_native_openharmony](https://example.com/[@rnoh](/user/rnoh)/react_native_openharmony)中的cpp目录
set(RNOH_CPP_DIR "${OH_MODULE_DIR}/@newlink/rn/oh_modules/[@rnoh](/user/rnoh)/react-native-openharmony/src/main/cpp")
更多关于HarmonyOS鸿蒙Next中OHPM私库依赖了另一个私库,这个被依赖的私库文件路径在哪的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
可以在DevEco Studio的终端 cd到entry模块,然后执行
ohpm i @rnoh/react-native-openharmony@x.x.x
xxx为版本号
这样就会在entry模块生成对应的文件
entry模块的CMakeList.txt中cpp目录为
set(RNOH_CPP_DIR "${OH_MODULE_DIR}/@rnoh/react-native-openharmony/src/main/cpp")
如果三方库依赖的rnoh的版本和工程依赖的版本不一致,可以在工程级的oh-package.json5中添加以下内容指定唯一版本
"overrides": {
"@rnoh/react-native-openharmony": "^0.72.48" //版本号根据实际来
}
更多关于HarmonyOS鸿蒙Next中OHPM私库依赖了另一个私库,这个被依赖的私库文件路径在哪的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
不知你需要的是不是这个
https://developer.huawei.com/consumer/cn/doc/harmonyos-faqs-V5/faqs-package-structure-38-V5
问题现象
例如有三个HAR分别为A、B、C,A依赖B,B依赖C。A是否可以引用C的资源?
解决措施
不支持A直接引用C的资源。A需要直接依赖C,即可引用。