HarmonyOS
Build a HarmonyOS preview of a Go app and sign its HAP.
nsgo build -target harmonyos -runharmonyos writes <name>-<version>-harmonyos.hap to dist/releases. The engine runs as WebAssembly in ArkWeb, and an ArkTS host draws what it mounts with ArkUI views, so text, fields, scrolling and dialogs are the system’s own. With hdc on PATH, -run installs the HAP on the connected device or emulator and starts it, and nsgo test -target harmonyos runs an app’s tests from an unsigned HAP on an emulator under a separate .nsgotest bundle identity, removing that test HAP after the run so the installed app remains available.
To compile the ArkTS host from the templates and use the app’s id as the bundle name, put hvigorw on PATH and set OHOS_BASE_SDK_HOME to an OpenHarmony SDK with API 26 (26.0.0), the templates’ compile and target SDK version. build.harmonyos_bundles picks auto, the default, exact, which requires the SDK, or padded, which pads the id to the committed host’s fixed length and needs no SDK. Target tests use the same setting and print which host they packaged. harmonyos.permissions lists the ohos.permission names the app asks for, such as MICROPHONE and CAMERA, and widget.title is what its home-screen card shows.
HarmonyOS is a preview. Emulators can install unsigned HAPs. The architecture notes list the ArkUI features the preview draws.
Signed HAPs
Section titled “Signed HAPs”Set harmonyos.signing to sign a HAP with your AppGallery Connect materials. A direct install on a Huawei phone needs a debug certificate and profile for that device. Use the release materials for distribution. Huawei signing guide
harmonyos: signing: keystore: signing/app.p12 key_alias: app certificate: signing/app.cer profile: signing/app.p7bPaths are relative to nsgo.yaml. Set NSGO_HARMONY_KEYSTORE_PASSWORD and NSGO_HARMONY_KEY_PASSWORD in the environment. Signing uses the SDK’s hap-sign-tool.jar and Java from JAVA_HOME or PATH. The build keeps the app’s exact id to match the profile, so signing needs the SDK and hvigorw even in auto mode. nsgo doctor, run in the app directory, checks the signing configuration and profile bundle name without passwords. build -run gives hdc the signed HAP.