function::remote_uri - Linux


Overview

function::remote_uri enables remote execution of functions in a Swift function (.swiftpm or .zip) hosted in a publicly accessible HTTP location.

Syntax

function::remote_uri [uri] [--timeout timeout] [--env env_value ...] [--secret-env secret_env_value ...]

Options/Flags

  • –timeout <timeout>: Timeout in milliseconds for the HTTP request. Default: 30000 (30 seconds)
  • –env <env_value>: Environment variables to be passed to the function. Can be specified multiple times.
  • –secret-env <secret_env_value>: Secret environment variables to be passed to the function. Sensitive values will not be shown in function logs. Can be specified multiple times.

Examples

Execute a function hosted at https://example.com/my-function.swiftpm:

function::remote_uri https://example.com/my-function.swiftpm

Set an environment variable named FOO with value BAR:

function::remote_uri https://example.com/my-function.swiftpm --env FOO=BAR

Pass a secret environment variable named MY_SECRET with value supersecret:

function::remote_uri https://example.com/my-function.swiftpm --secret-env MY_SECRET=supersecret

Common Issues

  • Ensure the provided URI is publicly accessible.
  • Verify that the function is executable on the server-side.
  • If --secret-env is not used, sensitive environment variables will be printed in function logs.

Integration

function::remote_uri can be integrated into scripts or combined with other commands to automate complex tasks, such as:

  • Combine with swift package generate-xcodeproj: Generate an Xcode project for a function hosted remotely:
swift package generate-xcodeproj --target "https://example.com/my-function.swiftpm"
  • Use with xcrun: Execute a remote function within an Xcode build script:
xcrun swift run --target "https://example.com/my-function.swiftpm" --env FOO=BAR

Related Commands