赞
踩
根据研究机构Counterpoint Research发布的最新数据,2024年第一季度,鸿蒙OS份额由去年一季度的8%上涨至17%,iOS份额则从20%下降至16%。这意味着,华为鸿蒙OS在中国市场的份额超越苹果iOS,已成中国第二大操作系统。
目前各大厂商纷纷与华为合作构建鸿蒙版移动应用,华为内部也主导适配目前的主流跨平台方案Flutter,并提供反向适配支持,此文将分享如何在Mac上构建鸿蒙App。
目前社区最新支持 Flutter 3.7.12 OpenHarmony-SIG/flutter_flutter (gitee.com)
nvm: github.com/nvm-sh/nvm
curl -o- raw.githubusercontent.com/nvm-sh/nvm/… | bash
ii): 添加环境变量到 ~/.zshrc
#nvm
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
i): 安装 node nvm install
$ nvm install 16
Now using node v16.9.1 (npm v7.21.1)
ii): 切换 node 版本 nvm use
arduino复制代码$ nvm use 16
Now using node v16.9.1 (npm v7.21.1)
iii): 查看 node 版本 nvm -v
$ node -v
v16.9.1
registry=https://repo.huaweicloud.com/repository/npm/
@ohos:registry=https://repo.harmonyos.com/npm/
鸿蒙签名工具基于 Gradle 7.1 编译构建(需要jdk11)
ohsdkmgr 必须jdk17+
brewinstallopenjdk@11brew install openjdk@11brewinstallopenjdk@11 brew install openjdk@17
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
17.0.9 (x86_64) "Homebrew" - "OpenJDK 17.0.9" /usr/local/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home
11.0.21 (x86_64) "Homebrew" - "OpenJDK 11.0.21" /usr/local/Cellar/openjdk@11/11.0.21/libexec/openjdk.jdk/Contents/Home
1.8.391.13 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
/usr/local/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
jenv add /usr/local/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home
$ jenv versions
system
1.8.0.391
11.0
11.0.21
17.0
* 17.0.9 (set by /Users/xxx/.jenv/version)
openjdk64-11.0.21
openjdk64-17.0.9
oracle64-1.8.0.391
$ jenv global 11.0.21
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment Homebrew (build 17.0.9+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.9+0, mixed mode, sharing)
export PATH=/Users/xxx/ohos/tools/gradle-7.1/bin:$PATH
$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=/Users/xxx/ohos/flutter/depot_tools:$PATH
solutions = [
{
"managed": False,
"name": "src/flutter",
"url": "git@gitee.com:openharmony-sig/flutter_engine.git",
"custom_deps": {},
"deps_file": "DEPS",
"safesync_url": "",
},
]
●Command Line Tools for HarmonyOS
●Command Line Tools for OpenHarmony
#Open Harmony SDK & HDC
export HDC_SERVER_PORT=7035
export OHPM_HOME=/Users/xxx/ohos/tools/oh-command-line-tools/ohpm
export PATH=/Users/xxx/ohos/tools/oh-command-line-tools/sdkmanager/bin:$PATH
export PATH=$PATH:$OHPM_HOME/bin
export OHOS_SDK_HOME=/Users/xxx/ohos/tools/oh-command-line-tools/sdk
export HDC_HOME=/Users/xxx/ohos/tools/oh-command-line-tools/sdk/11/toolchains
#export HDC_HOME=/Users/xxx/ohos/tools/hwsdk/openharmony/9/toolchains
export PATH=$PATH:$HDC_HOME
export PATH=/Users/xxx/ohos/tools/command-line-tools/sdkmanager/bin:$PATH
export HOS_SDK_HOME=/Users/xxx/ohos/tools/hwsdk
●sdk/11/ets/build-tools/ets-loader
●sdk/11/js/build-tools/ace-loader
编译出来的产物
●ohos_debug_unopt_arm64
●ohos_release_arm64
git clone https://gitee.com/openharmony/developtools_hapsigner.git
#Harmony sign tool
export SIGN_TOOL_HOME=/Users/xxx/ohos/tools/developtools_hapsigner/autosign
{ "version-name": "2.0.0", "version-code": 2, "app-distribution-type": "os_integration", "uuid": "5027b99e-5f9e-465d-9508-a9e0134ffe18", "validity": { "not-before": 1594865258, "not-after": 1689473258 }, "type": "release", "bundle-info": { "developer-id": "OpenHarmony", "distribution-certificate": "-----BEGIN CERTIFICATE-----\nMIICSTCCAc+gAwIBAgIFAJV7uNUwCgYIKoZIzj0EAwIwYzELMAkGA1UEBhMCQ04x\nFDASBgNVBAoMC09wZW5IYXJtb255MRkwFwYDVQQLDBBPcGVuSGFybW9ueSBUZWFt\nMSMwIQYDVQQDDBpPcGVuSGFybW9ueSBBcHBsaWNhdGlvbiBDQTAeFw0yMjAxMjkw\nNTU0MTRaFw0yMzAxMjkwNTU0MTRaMGgxCzAJBgNVBAYTAkNOMRQwEgYDVQQKDAtP\ncGVuSGFybW9ueTEZMBcGA1UECwwQT3Blbkhhcm1vbnkgVGVhbTEoMCYGA1UEAwwf\nT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUmVsZWFzZTBZMBMGByqGSM49AgEGCCqG\nSM49AwEHA0IABAW8pFu7tHGUuWtddD5wvazc1qN8ts9UPZH4pecbb/bSFWKh7X7R\n/eTVaRrCTSSdovI1dhoV5GjuFsKW+jT2TwSjazBpMB0GA1UdDgQWBBScyywAaAMj\nI7HcuIS42lvZx0Lj+zAJBgNVHRMEAjAAMA4GA1UdDwEB/wQEAwIHgDATBgNVHSUE\nDDAKBggrBgEFBQcDAzAYBgwrBgEEAY9bAoJ4AQMECDAGAgEBCgEAMAoGCCqGSM49\nBAMCA2gAMGUCMFfNidGo6uK6KGT9zT1T5bY1NCHTH3P3muy5X1xudOgxWoOqIbnk\ntmQYB78dxWEHLQIxANfApAlXAD/0hnyNC8RDzfLOPEeay6jU9FXJj3AoR90rwZpR\noN9sYD6Oks4VGRw6yQ==\n-----END CERTIFICATE-----\n", "bundle-name": "{{ohosId}}", "apl": "normal", "app-feature": "hos_normal_app" }, "acls": { "allowed-acls": [ "" ] }, "permissions": { "restricted-permissions": [] }, "issuer": "pki_internal" }
●autosign.config
●createAppCertAndProfile.config
修改值:sign.profile.inFile=profile_tmp.json
git clone https://gitee.com/openharmony-sig/flutter_flutter.git
#Harmony flutter
export PATH=/Users/xxx/ohos/flutter/flutter_flutter/bin:$PATH
export PATH=/Users/xxx/ohos/flutter/flutter_flutter/bin/cache/dart-sdk/bin:$PATH
export PATH=/Users/xxx/ohos/flutter/flutter_flutter/.pub-cache/bin:$PATH
export FLUTTER_GIT_URL=https://gitee.com/openharmony-sig/flutter_flutter.git
export PUB_HOSTED_URL=https://pub.flutter-io.cn
[✓] Flutter (Channel master, 3.7.12, on macOS 12.7 21G816 darwin-x64, locale zh-Hans-CN)
• Flutter version 3.7.12 on channel master at /Users/xxx/ohos/flutter/flutter_flutter
• Upstream repository https://gitee.com/openharmony-sig/flutter_flutter.git
• FLUTTER_GIT_URL = https://gitee.com/openharmony-sig/flutter_flutter.git
• Framework revision 00cc3dce34 (2 weeks ago), 2023-12-11 13:38:48 +0000
• Engine revision 1a65d409c7
• Dart version 2.19.6
• DevTools version 2.20.1
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] OpenHarmony toolchain - develop for OpenHarmony devices
• OpenHarmony Sdk location: /Users/xxx/ohos/tools/oh-command-line-tools/sdk, available api versions has [9, 10]
• hdc version 2.0.0
• ohpm version 1.2.0
• signTool location:/Users/xxx/ohos/tools/developtools_hapsigner/autosign
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
• Android SDK at /Users/xxx/Library/Android/sdk
• Platform android-33, build-tools 33.0.2
• ANDROID_HOME = /Users/xxx/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/900330
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。