好多人在纯撸鸿蒙,极少公司走鸿蒙+flutter的路线,你们想走这个路线的,我给你们趟坑了我做的时候是24年3月份,那会好多库 不支持,让给官方提供了一下我的项目里面的库,后来他们填完,基本一半 不支持,如今6月份了,适配的差不多了,flutter_flutter 也升级了,对应鸿蒙api12的 flutter版本也已经升级了。
如何在MacOS 上使用 Flutter 构建鸿蒙App
1、相关库主要是2个
Flutter 3.7.12 https://gitee.com/openharmony-sig/flutter_flutter
flutter 引擎 https://gitee.com/openharmony-sig/flutter_engine
2、环境相关配置
如何在MacOS 上使用 Flutter 构建鸿蒙App
看这个靠谱mac配置环境变量
如何windos上使用flutter 构建鸿蒙app
可以看看windos配置环境变量 (没验证哈,博主用的mac)
3、最后mac的配置表如下
open ~/.zshrc 打开配置页面
下面是我的flutter +鸿蒙相关的 配置信息
exportNVM_DIR="$HOME/.nvm"[-s"$NVM_DIR/nvm.sh"]&&\. "$NVM_DIR/nvm.sh"# This loads nvm[-s"$NVM_DIR/bash_completion"]&&\. "$NVM_DIR/bash_completion"# This loads nvm bash_completion# HomeBrewexportHOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
exportPATH="/usr/local/bin:$PATH"exportPATH="/usr/local/sbin:$PATH"eval"$(/opt/homebrew/bin/brew shellenv)"# HomeBrew END#JAVAexportPATH="$HOME/.jenv/bin:$PATH"eval"$(jenv init -)"#Python3exportPATH="/opt/homebrew/opt/[email protected]/libexec/bin:$PATH"# Node配置exportNODE_HOME="/Users/xxxx/.nvm/versions/node/v18.19.1"####################################################################################################################### Flutter 镜像配置exportPUB_HOSTED_URL=https://pub.flutter-io.cn
exportFLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
# Flutter 配置#export FLUTTER=/opt/flutter/binexportFLUTTER=/Users/xxxx/ohos/flutter_flutter/bin
exportPATH=$FLUTTER:$PATH# Harmony flutterexportPUB_HOSTED_URL=https://pub.dev
exportFLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
#export FLUTTER_GIT_URL=OpenHarmony-SIG/flutter_flutterexportFLUTTER_GIT_URL=https://gitee.com/openharmony-sig/flutter_flutter.git
# MAVENexportMAVEN_HOME=/Users/xxxx/ohos/tools/apache-maven-3.9.6
exportPATH=$PATH:$MAVEN_HOME/bin
#Dart配置exportPATH=$PATH:/Users/xxxx/ohos/flutter_flutter/bin/cache/dart-sdk/bin
# Open Harmony 配置exportOHPM_HOME=/Users/xxxx/ohos/tools/oh-command-line-tools/ohpm
exportPATH=$PATH:$OHPM_HOME/bin
exportPATH=$PATH:/Users/xxxx/ohos/tools/oh-command-line-tools/sdkmanager/bin
#export OHOS_SDK_HOME=/Users/xxxx/ohos/OpenHarmony/Sdk/11exportOHOS_SDK_HOME=/Users/xxxx/ohos/OpenHarmony/Sdk/12
exportOHOS_NDK_HOME=$OHOS_SDK_HOME/native
exportPATH=$PATH:$OHOS_NDK_HOME# Harmony配置exportHOS_SDK_HOME=/Users/xxxx/ohos/Huawei/Sdk
#export PATH=$PATH:$HOS_SDK_HOMEexportHPM_HOME=/Users/xxxx/ohos/tools/command-line-tools/ohpm
exportPATH=$PATH:$HPM_HOME/bin
#export PATH=$PATH:/Users/xxxx/ohos/tools/command-line-tools/sdkmanager/binexportPATH=$PATH:/Users/xxxx/ohos/tools/command-line-tools/bin
#HDC工具环境变量exportHDC_HOME=/Users/xxxx/ohos/Huawei/Sdk/HarmonyOS-NEXT-DB1/hms/toolchains
#export HDC_HOME=/Users/xxxx/ohos/Huawei/Sdk/HarmonyOS-NEXT-DP2/base/toolchainsexportPATH=$PATH:$HDC_HOME#签名工具exportSIGN_TOOL_HOME=/Users/xxxx/ohos/tools/developtools_hapsigner/hapsigntool/hap_sign_tool/target
4、闲聊
博主第一次配置完成需要了3,4天,那个引擎产物有点复杂,各种环境,有的和版本有要求,一定要静下心来,配置过一次的就好 了,后面的同事可以复制粘贴了,加油兄弟们!
版权归原作者 甄兴旺 所有, 如有侵权,请联系我们删除。