Debug Your Lightning Web Component Into Salesforce Mobile Applications

Prashant Torawane
Globant
Published in
5 min readFeb 22, 2024
Source: pxfuel.com

Debugging Lightning Web Components in Salesforce Mobile Applications can sometimes be challenging. A simulator can simplify debugging and save time. In this blog, we will explore how to debug Lightning Web Components into the Salesforce mobile application using a simulator. Before you jump into the text, I assume you already have a page or a Lightning Web Component available.

What is a Simulator?

A simulator is a tool that enables you to test and debug your mobile application components. You don’t need a physical device to use it. It emulates a mobile device’s behavior. It enables you to replicate and analyze issues that may occur on different platforms.

Before we go into the debugging process, let’s first set up the simulator. We will walk you through the complete process for iOS and Android devices.

Steps to follow for iOS

  1. Before you start, download and install the latest version of Xcode.
  2. Open Xcode.
Step 2. Xcode initial screen

3. In Menu, select Xcode → open developer tool → Simulator. You will get a new simulator screen.

Step 3. Open Simulator

4. In Menu, select File → open simulator → choose any one device on which you want to debug your component. For this blog, let’s open the iPhone 15.

Step 4. Choose a device on the simulator

Steps to follow for Android

  1. Before you start, download and install the latest version of Android Studio.
  2. Open Android Studio.
  3. On the welcome page, select more actions → virtual device manager. A new window will open with the list of existing devices.
Step 3. Android Studio’s initial screen

4. Click on the Create new device (+) icon.

Step 4. Create a new virtual device

5. In the new window, select your preferred device and click Next.

6. You may need to download a release before proceeding. Select a Release and click Next.

7. Click on the icon (▷) to run the simulator.

Step 6. Download required setup

How to install the Salesforce Mobile Application on the simulator

You must have installed the Salesforce mobile application on the simulator to debug. You can do this by downloading the application from Salesforce mobile tools. Then, drag the application file onto the simulator screen.

  1. Install the Salesforce mobile application for simulators from Salesforce mobile tools.
  2. Select as per your preference → iOS or Android.
  3. If you will redirect to another page, then click continue.
  4. If you are using iOS, then extract the downloaded zip file. You will get one “chatter.app” for iOS. For Android, you will get a “.apk” file.
  5. Drag the extracted “chatter.app” or “.apk” file onto the simulator screen.
  6. Scroll your simulator screen to find out the application.
Salesforce mobile app

How to use debugging tools (Safari / Chrome)

We can use debugging tools to debug components running on mobile applications. We can use Safari Inspector and Google DevTools. The only difference is how to set it up.

How to Enable Debug Mode

The first step is to enable Debug mode in your salesforce instance for your user.

  1. From Setup, enter Debug mode in the quick find box, then select Debug mode.
  2. In the user list, select the checkbox next to your user. Click “Enable”.

Steps to use debugging tools

  1. Open the Salesforce application.
  2. Click on “I Accept”.
  3. Log in with your credentials. Click on “Allow Access”.
  4. Open the page on which your lightning web component is available for debugging.
  5. Open Safari browser for iOS and Chrome for Android debugging.

Note: If you are using iOS, you should enable “develop” on Safari with the following steps.

From the menu, select Safari → settings → advance → check “show features for web developers.

Enable development for safari

8. Click Develop → select your simulator Device → select your page.

Step 8. Safari develop

9. You can see the browser console.

Step 9. Browser console

Note: If you are using Android, you should enable developer mode for the Android emulator using these steps.

How to Enable Developer Mode for Emulator

  1. On your emulated Android device, open the Settings application.
  2. Enter “About emulated device” into the search bar and select it.
  3. Scroll to the bottom of the page and click “Build number” 7 times.
  4. You will get a message like “You are now a developer!”. The emulator has developer mode enabled.
Android emulator

5. Open Chrome on your desktop and search for (chrome://inspect/#devices).

Chrome console

6. Click “inspect” under the Remote Target. You will get a screen like the below image.

Debugging on Chrome console

Hurray! You have successfully configured your device for debugging.

Now, you can debug your components using the Browser Console.

Conclusion

By following this blog, you can configure your device for debugging. You can also use the browser console to debug your Lightning Web Components. You can do this in the Salesforce mobile application. The simulator allows you to identify and resolve any issues or bugs. It ensures a smooth and error-free user experience for your mobile application users.

References

Set Up Your Salesforce Mobile Developer Tools for Lightning Web Components.

--

--