Skip to content

Running your bot

Instructions are available per platform.

Ensure the scheme is set to your bot, and press the run button. It will build for debugging unless you change the scheme settings. Xcode screenshot highlighting run button

With a terminal

Open a terminal, cd to your bot project directory, and paste the following command.

Terminal window
swift run


Deployment

Binary (for macOS)

We recommend this if you’re hosting on a macOS server, and your bot relies on macOS frameworks.

Begin by building your bot for release with the following command:

Terminal window
swift build -c release

The final binary will be located in a folder in the .build/ folder. The destination folder will be named after your host architecture.

You can then copy the binary and required resources to your server, and run it with any required arguments or environment variables.

To ensure the bot launches on boot, you can use a launchd plist. You can find more information on launchd plists at Apple’s developer documentation.

We recommend this if you’re hosting on a Linux server, or if you’re hosting on a macOS server but don’t deal with macOS frameworks.

First, make sure you have docker and docker-compose installed. You can install them using your distro’s package manager, or by using the official Docker installation script, located here.

Start by making a Dockerfile in your bot project directory. It might look something like this:

FROM swift:6.0.2-jammy AS build
WORKDIR /app
COPY . .
RUN swift build -c release
FROM swift:6.0.2-jammy-slim AS runtime
COPY --from=build /app/.build/release/your-app /usr/local/bin/your-app
ENTRYPOINT ["your-app"]

This example Dockerfile builds your bot using a full swift image, and runs it on a smaller, more optimized image.

You can then run the newly-created docker image with docker run, however it is highly recommended to use docker-compose. A minimal docker-compose.yml may look like this:

services:
your-app:
build: .

Start the docker image by running docker compose up -d in the same directory as the compose file.

If you need to specify environment variables or other options, you can find a more in-depth example here.

Special

If you’re hosting on an iDevice, you can use the same instructions as running on an iDevice. There is no better way to deploy on an iDevice, as it’s not recommended. You can be assured that it’s at least safe and sandboxed unless you used the jailbroken method. But it’s not recommended for production use anyways. Maybe just useful for flexing on your friends idk.