DEV Community

HarmonyOS
HarmonyOS

Posted on

Creating and Configuring SysCap File for Wearables

Read the original article:Creating and Configuring SysCap File for Wearables

Creating and Configuring SysCap File for Wearables

Requirement Description

Wearable apps require correct SysCap configuration to access supported system features and avoid build errors.

Background Knowledge

SysCap (System Capability) defines which system APIs are available.

Implementation Steps

Create entry/src/main/syscap.json

Enter the required SysCaps in the following format. The following is an example of the syscap.json file for using the FileIO capability

{
  "devices": {
    "general": [
      // Each typical device corresponds to a SysCap set. Multiple typical devices can be configured. The devices must be the same as those selected in the project.
      "phone"
    ]
  },
  "development": {
    // The SysCap set in addedSysCaps and the SysCap set supported by each device configured in devices form the associated SysCap set.
    "addedSysCaps": [
      "SystemCapability.FileManagement.File.FileIO",
    ]
  }
}

Enter fullscreen mode Exit fullscreen mode

Limitation or Considerations

Unsupported SysCaps cause build failure. Use canIUse() defined by the system to check whether a SysCap is supported.

if (canIUse("SystemCapability.ArkUI.ArkUI.Full")) {

console.log("This device supports SystemCapability.ArkUI.ArkUI.Full.");

} else {

console.log("This device does not support SystemCapability.ArkUI.ArkUI.Full.");

}
Enter fullscreen mode Exit fullscreen mode

Related Documents or Links

https://developer.huawei.com/consumer/en/doc/harmonyos-references-V5/syscap-V5

Written by Emrecan Karakas

Top comments (0)