For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/guide/start/integrate-lynx-devtool.md.
Lynx
  • English
  • Integrating Lynx DevTool

    When encountering issues during Lynx page development, you can use DevTool for debugging. However, you need to follow these steps to integrate DevTool first.

    Info

    It is recommended to integrate DevTool in non-production environments to keep your production builds lightweight.

    • Package size: DevTool will increase the package size.
    • Runtime: Related modules are lazy loaded when enabled, which will increase memory overhead, and some features may affect the loading performance.

    All code examples in this documentation can be found in the integrating-lynx-demo-projects.

    Adding Dependencies

    You need to add these components: the Devtool subcomponent of LynxService, LynxDevTool, and DebugRouter.

    Podfile
    # Ensure Lynx DevTool version matches the Lynx version when integrating
    target 'YourTarget' do
      pod 'LynxService', '4.0.0', :subspecs => [
          'Devtool',
      ]
      pod 'LynxDevtool', '4.0.0'
    
      pod 'DebugRouter', '5.0.15'
      pod 'DebugRouter/MessageTransceiverEnable', '5.0.15'
    end

    Enabling DevTool

    DevTool provides several debugging switches. Here are some important switches:

    • Lynx DevTool controls main debugging features: element inspection and JavaScript debugging.
    • Lynx LogBox manages the LogBox.
    These switches are disabled by default, you need to enable them.
    • Lynx DevTool and Lynx LogBox switches can only take effect after DevTool is in ENABLED state.
    • When debugging Lynx pages with the DevTool Desktop, Lynx DevTool needs to be enabled.
    • LogBox helps you quickly identify and diagnose issues.

    You can configure these switches during Lynx Environment Initialization:

    Objective-C
    Swift
    AppDelegate.m
    #import <Lynx/LynxEnv.h>
    #import <Lynx/LynxService.h>
    #import <Lynx/LynxServiceDevToolProtocol.h>
    
    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      // ...
      LynxEnv *lynxEnv = [LynxEnv sharedInstance];
      // Enable all sessions debugging for DevTool (required for Lynx DevTool Desktop connection)
      [LynxService(LynxServiceDevToolProtocol) enableAllSessions];
      // Enable Lynx DevTool Switch
      lynxEnv.devtoolEnabled = YES;
      // Enable Lynx LogBox Switch
      lynxEnv.logBoxEnabled = YES;
      return YES;
    }
    Info

    In addition to the three switches introduced earlier, there are more switches that can help you control the behavior of DevTool. Please refer to the Lynx DevTool Switch Page.

    Adding Dependencies

    You need to integrate these two components: lynx-service-devtool and lynx-devtool

    build.gradle
    build.gradle.kts
    // Ensure Lynx DevTool version matches the Lynx version when integrating
    dependencies {
      implementation "org.lynxsdk.lynx:lynx-devtool:4.0.0"
      implementation "org.lynxsdk.lynx:lynx-service-devtool:4.0.0"
    }
    Info

    It is recommended to use the latest Lynx version when integrating

    Registering DevTool Service

    Java
    Kotlin
    YourApplication.java
    private void initLynxService() {
      // ...
      // register DevTool service
      LynxServiceCenter.inst().registerService(LynxDevToolService.getINSTANCE());
    
      // enable all sessions debug for DevTool (required for Lynx DevTool Desktop connection)
      LynxDevToolService.getINSTANCE().enableAllSessions();
    }
    

    Enabling DevTool

    DevTool provides several debugging switches. Here are some important switches:

    • Lynx DevTool controls main debugging features: element inspection and JavaScript debugging.
    • Lynx LogBox manages the LogBox.
    These switches are disabled by default, you need to enable them.
    • Lynx DevTool and Lynx LogBox switches can only take effect after DevTool is in ENABLED state.
    • When debugging Lynx pages with the DevTool Desktop, Lynx DevTool needs to be enabled.
      • If you need to use JavaScript debugging, you also need to set the LoadQJSBridge or LoadV8Bridge bootstrap value to true.
        • LoadQJSBridge controls loading the PrimJS engine debugging library.
        • LoadV8Bridge controls loading the V8 engine debugging library.
    • LogBox helps you quickly identify and diagnose issues.

    You can configure these switches during Lynx Environment Initialization:

    Java
    Kotlin
    YourApplication.java
    private void initLynxEnv() {
      LynxEnv.inst().init(this, null, null, null);
      // Advance DevTool to ENABLED state
      LynxEnv.inst().enableLynxDebug(true);
      // Enable Lynx DevTool Switch
      LynxEnv.inst().enableDevtool(true);
      // Enable Lynx LogBox Switch
      LynxEnv.inst().enableLogBox(true);
    }
    
    Info

    In addition to the three switches introduced earlier, there are more that can help you control the behavior of DevTool. Please refer to the DevTool Switch Page.

    Adding Dependencies

    You need to integrate these two components: @lynx/lynx_devtool and @lynx/lynx_devtool_service.

    oh-package.json5
    build-profile.json5
    // Ensure Lynx DevTool version matches the Lynx version when integrating
    "dependencies": {
      "@lynx/lynx_devtool": "@param:dependencies.lynx_version",
      "@lynx/lynx_devtool_service": "@param:dependencies.lynx_version"
    }
    Info

    It is recommended to use the latest Lynx version when integrating

    Registering DevTool Service

    ETS
    YourEntryAbility.ets
    // Initialize LynxDevToolService first, as LynxEnv initialization
    // depends on LynxDevToolService from LynxService
    LynxServiceCenter.registerService(
      LynxServiceType.DevTool,
      LynxDevToolService.instance,
    );

    Enabling DevTool

    DevTool provides several debugging switches. Here are some important switches:

    • Lynx DevTool controls main debugging features: element inspection and JavaScript debugging.
    • Lynx LogBox manages the LogBox.
    LogBox is on by default, DevTool is off. Enabling DevTool is recommended.
    • Lynx DevTool and Lynx LogBox switches can only take effect after DevTool is in ENABLED state.
    • When debugging Lynx pages with the DevTool Desktop, Lynx DevTool needs to be enabled.
    • LogBox helps you quickly identify and diagnose issues.

    You can configure these switches during Lynx Environment Initialization:

    ETS
    YourEntryAbility.ets
    public initLynxEnv() {
      LynxEnv.initialize(this.context);
    
      // Advance DevTool to ENABLED state
      LynxEnv.enableLynxDebug(true);
      // Enable Lynx DevTool Switch
      LynxEnv.enableDevtool(true);
      // Enable Lynx LogBox Switch
      LynxEnv.setLogBoxEnabled(true);
    }
    
    Info

    In addition to the three switches introduced earlier, there are more that can help you control the behavior of DevTool. Please refer to the DevTool Switch Page.

    Congratulations! You have completed the DevTool integration. Now, you may launch the Lynx DevTool Desktop and connect your app via USB to start debugging.

    Integrate Lynx DevTool Successfully

    Compatibility

    LCD tables only load in the browser

    Next Step

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.