A quick introduction to ArkUI-X framework development [Nut Pie]

A quick introduction to ArkUI-X framework development

ArkUI framework

ArkUI is a declarative UI development framework for building distributed applications. It has simple and natural UI information syntax, rich UI components, multi-dimensional state management, and real-time interface preview tools to help you improve application development efficiency and achieve a vivid and smooth user experience on a variety of devices.

ArkUI-X

ArkUI-X further extends ArkUI to multiple OS platforms: it currently supports OpenHarmony, HarmonyOS, Android, and iOS, and more platform support will be gradually added in the future. Based on one master code, developers can build beautiful, high-performance applications that support multiple platforms.

API extension

API extension includes two parts:

The first is to reuse the OpenHarmony NAPI mechanism and implement the OpenHarmony interface definition on Android and iOS platforms;

The second is to support developers to expand business plug-ins based on Android and iOS platform interface capabilities or third-party library capabilities.

Environmental preparation

  • The compilation environment requires Ubuntu 18.04 and above, and macOS requires 11.6.2 and above.

  • Install the packages required for compilation.

    [Linux]

    sudo apt-get install binutils git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4
    

    [macOS]

    brew install wget coreutils
    

Configure Java environment

Note: It is recommended to download JDK11.0.2 or above. Please click here to download .

[Linux]

// 配置环境变量
export JAVA_HOME=/home/usrername/path-to-java-sdk
export PATH=${JAVA_HOME}/bin:${PATH}

[macOS]

// 配置环境变量
export JAVA_HOME=/Users/usrername/path-to-java-sdk
export PATH=$JAVA_HOME/bin:$PATH

Configure Android SDK environment

[Linux]

Download and manage the Android SDK through the command line tool . For instructions on using the command line tool, see the official guidance of sdkmanager . The SDK version download requirements are as follows:

./sdkmanager --install "ndk;21.3.6528147" --sdk_root=/home/usrername/path-to-android-sdk
./sdkmanager --install "platforms;android-26" --sdk_root=/home/usrername/path-to-android-sdk
./sdkmanager --install "build-tools;28.0.3" --sdk_root=/home/usrername/path-to-android-sdk
// 配置环境变量
export ANDROID_HOME=/home/usrername/path-to-android-sdk
export PATH=${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/build-tools/28.0.3:${ANDROID_HOME}/platform-tools:${PATH}

[macOS]

Download and manage the Android SDK through the IDE SDK manager . The NDK version requirement is: 21.3.6528147, and the SDK Platform version is: 26.

// 配置环境变量
export ANDROID_HOME=/Users/usrername/path-to-android-sdk
export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/build-tools/28.0.3:$ANDROID_HOME/platform-tools:$PATH

Configure iOS SDK environment

  • Xcode and Command Line Tools for Xcode applications can be downloaded and installed from the Mac App Store.

  • Command Line Tools can also be installed using the command method:

    xcode-select --install
    

ArkUI-X code download

Prerequisites

  1. Register a code cloud gitee account.

  2. To register the Code Cloud SSH public key, please refer to the Code Cloud Help Center .

  3. Install the git client and git-lfs and configure user information.

    git config --global user.name "yourname"
    git config --global user.email "your-email-address"
    git config --global credential.helper store
    
  4. To install the code cloud repo tool, you can execute the following command.

    curl -s https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo  #如果没有权限,可下载至其他目录,并将其配置到环境变量中
    chmod a+x /usr/local/bin/repo
    pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
    

Download method

  • ArkUI-X main code acquisition

    Method 1 (recommended): Download via repo + ssh (requires registration of public key, please refer to Code Cloud Help Center ).

    mkdir arkui
    cd arkui
    repo init -u [email protected]:arkui-x/manifest.git -b master --no-repo-verify
    repo sync -c --no-tags -j12
    

    Method 2: Download via repo + https.

    mkdir arkui
    cd arkui
    repo init -u https://gitee.com/arkui-x/manifest.git -b master --no-repo-verify
    repo sync -c
    repo forall -c 'git lfs pull'
    
  • ArkUI-X development branch code acquisition

    Method 1 (recommended): Download via repo + ssh (requires registration of public key, please refer to Code Cloud Help Center ).

    mkdir arkui
    cd arkui
    repo init -u [email protected]:arkui-x/manifest.git -b master --no-repo-verify -m arkui-dev.xml
    repo sync -c --no-tags -j12
    

    Method 2: Download via repo + https.

    mkdir arkui
    cd arkui
    repo init -u https://gitee.com/arkui-x/manifest.git -b master --no-repo-verify -m arkui-dev.xml
    repo sync -c --no-tags -j12
    

ArkUI-X compilation

Compile the script using build.sh

Use the build.sh compilation script to compile, common options for compilation scripts

--product-name    # 必须  编译的产品名称,如:arkui-x
--target-os       # 必须  编译的跨平台目标,如:android或ios
--target-cpu      # 可选  指定target侧CPU架构,如:arm或arm64
--build-target    # 可选  指定编译目标,可以指定多个
--gn-args         # 可选  gn参数,支持指定多个
--ninja-args      # 可选  ninja参数,如:--ninja-args=-dkeeprsp
--log-level       # 可选  指定log等级,如:info或debug
--help, -h        # 可选  命令行help辅助命令

When downloading new code or updating code, you need to download or update the precompiled tool chain. The command is as follows

./build/prebuilts_download.sh --build-arkuix

Compilation command example

View the options supported by the compile script

./build.sh -h

ArkUI-X Android platform compilation command:

./build.sh --product-name arkui-x --target-os android

ArkUI-X iOS platform compilation command:

./build.sh --product-name arkui-x --target-os ios

Guess you like

Origin blog.csdn.net/qq_39132095/article/details/132788669