For the cli to work properly on linux, usbutils
needs to be installed.
The CLI currently assumes that the Swift toolchain is installed at /Library/Developer/Toolchains/swift-6.1-RELEASE.xctoolchain
. You can obtain a copy of this toolchain here. During the installation of the toolchain pkg, you need to select "Install for all users of this computer".
Before installing the SDK in the next step, export theTOOLCHAINS
environment variable:
export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/swift-6.1-RELEASE.xctoolchain/Info.plist)
After installing the toolchain and exporting the TOOLCHAINS
variable, you need to install the Swift Static Linux SDK. This step is necessary on all platforms (including macOS).
swift sdk install https://download.swift.org/swift-6.1-release/static-sdk/swift-6.1-RELEASE/swift-6.1-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz
We have a Homebrew Tap to install the developer CLI on macOS.
brew tap edgeengineer/tap
brew install edge
To update the CLI on macOS:
brew upgrade edge
The device needs to run the edge-agent
utility. We provide pre-build EdgeOS images for the Raspberry Pi and the NVIDIA Jetson Orin Nano. These are preconfigured for remote debugging and have the edge-agent preinstalled.
The edge
CLI communicates with an edge-agent
. The agent needs uses Docker for running your apps, so Docker needs to be running.
On a Debian (or Ubuntu) based OS, you can do the following:
# Install Docker
sudo apt install docker.io
# Start Docker and keep running across reboots
sudo systemctl start docker
sudo systemctl enable docker
# Provide access to Docker from the current user
sudo usermod -aG docker $USER
Then, you can download and run your edge-agent
on the device. We provide nightly tags with the latest edge-agent
builds in this repository.
If you're planning to test the edge-agent on macOS, you'll need to build and run the agent yourself from this repository.
swift run edge-agent
You can run the hello world example by executing the following command:
cd Examples/HelloWorld
swift run --package-path ../../ -- edge run --agent <hostname-of-device>
This will build the Edge CLI and execute it's run
command. The Edge CLI will in turn build the
HelloWorld
example using the Swift Static Linux SDK, and run it in a Docker container.
A more advanced example demonstrating HTTP server capabilities is available in the HelloHTTP
directory:
cd Examples/HelloHTTP
swift run --package-path ../../ -- edge run --agent <hostname-of-device>
To debug examples, you can use the following command:
swift run --package-path ../../ -- edge run --agent <hostname-of-device> --debug
You can now attach the LLDB debugger through using port 4242
.
To start an LLDB debugging session from the CLI, run lldb
from the Terminal:
lldb
Then, from within LLDB's prompt run the following to connect to your app's debugging session:
(lldb) target create .edge-build/debug/HelloWorld
(lldb) settings set target.sdk-path "<path-to-sdk.artifactbundle>/swift-6.1-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64"
(lldb) settings set target.swift-module-search-paths "<path-to-sdk.artifactbundle>/swift-6.1-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64/usr/lib/swift_static/linux-static"
(lldb) gdb-remote localhost:4242
Unfortunately, running expressions (e.g. po
) doesn't work yet.