LinuxCommandLibrary

sfdk-emulator

Emulate Salesforce Functions locally for development

TLDR

Display the installed emulators

$ sfdk emulator list
copy

Start an emulator
$ sfdk emulator start [name]
copy

Stop an emulator
$ sfdk emulator stop [name]
copy

Display emulator status
$ sfdk emulator status [name]
copy

Run an interactive shell on an emulator
$ sfdk emulator exec [emulator]
copy

Execute a command on an emulator
$ sfdk emulator exec [emulator] [command]
copy

Set a property
$ sfdk emulator set [name] [property]=[value]
copy

Show emulator properties
$ sfdk emulator show [name]
copy

SYNOPSIS

sfdk-emulator action [options] [emulator_name]
Common actions include:
sfdk-emulator list
sfdk-emulator start emulator_name
sfdk-emulator stop emulator_name
sfdk-emulator create emulator_name [options]
sfdk-emulator connect emulator_name

PARAMETERS

action
    Specifies the operation to perform (e.g., list, start, stop, create, delete, connect, reboot, status).

emulator_name
    The unique name of the emulator instance to operate on.

--sdk-version <version>
    (Used with create) Specifies the Sailfish OS version to install on the emulator.

--target <target_name>
    (Used with create) Selects a specific SDK target configuration for the emulator.

--device-type <type>
    (Used with create) Defines the emulated device profile (e.g., phone, tablet).

--qemu-options "<options>"
    Passes additional QEMU command-line options directly to the underlying emulator process.

-v, --verbose
    Enables verbose output, displaying more detailed information about the operation.

-h, --help
    Displays general help or help for a specific action.

DESCRIPTION

The sfdk-emulator command is an essential utility within the Sailfish OS SDK (SFDK). It provides developers with a comprehensive set of tools to manage and interact with Sailfish OS emulators. These emulators are typically virtual machines, often based on QEMU, that run the Sailfish OS environment on a desktop Linux system. This allows developers to test applications, debug code, and verify functionality without requiring a physical Sailfish OS device.

The command facilitates various operations, including listing available emulators, creating new emulator instances with specific configurations (like Sailfish OS versions or device profiles), starting and stopping running emulators, and establishing connections to them for development purposes (e.g., SSH, adb-like access). It streamlines the development workflow by providing a consistent and reproducible testing environment, crucial for porting applications or developing new ones for the Sailfish OS platform.

CAVEATS

sfdk-emulator requires the Sailfish OS SDK to be fully installed and configured on a Linux host. It is resource-intensive, as emulators consume significant CPU, RAM, and disk space. Network configuration for the emulator can sometimes be complex, requiring adjustments for internet access or host-guest communication. Compatibility with specific Linux distributions or kernel versions might vary. Users should also ensure they have sufficient disk space for emulator images and snapshots.

DEVELOPER WORKFLOW

A typical workflow involves first using sfdk-emulator create to set up an emulator with a desired Sailfish OS version. Then, sfdk-emulator start launches the virtual machine. Developers can then use sfdk-emulator connect to gain shell access or use SDK tools like sfdk deploy to push applications to the running emulator for testing. Finally, sfdk-emulator stop is used to shut down the instance.

QEMU INTEGRATION

While sfdk-emulator abstracts much of the complexity, it relies heavily on QEMU for virtualization. Understanding basic QEMU concepts can be beneficial for advanced debugging or custom configurations, especially when using the --qemu-options flag. Network issues are often related to QEMU's networking setup.

HISTORY

The sfdk-emulator command, along with the broader Sailfish OS SDK, was developed by Jolla Ltd. and its partners to facilitate application development for the Sailfish OS mobile operating system. It emerged as a crucial component during the early stages of Sailfish OS, providing developers with a robust and accessible environment to test their software without constant reliance on physical devices. Its design reflects the need for a comprehensive developer experience, integrating closely with the SDK's build and deployment tools. Over time, it has evolved with Sailfish OS versions, adapting to new architectures and features while maintaining its core purpose of enabling efficient emulator-based development.

SEE ALSO

sfdk(1), qemu(1), ssh(1)

Copied to clipboard