Hello World in Swift
Create your first WendyOS application using Swift
Creating Your First Swift Application
This guide will walk you through creating a simple "Hello, World!" application for WendyOS using Swift. This is a great way to prove that you can send your first app to your device and verify your development environment is set up correctly.
Prerequisites
- Wendy CLI installed on your development machine
- Swift 6.2 or later installed
- A WendyOS device plugged in over USB or connectable over Wi-Fi
Creating the Project
Initialize the Project
Run the Wendy CLI initialization command:
wendy initThis creates a new Swift project structure with all the necessary files for a WendyOS application.
Explore the Project Structure
After initialization, you'll have the following structure:
hello-world/
├── Package.swift
└── Sources/
└── hello-world/
└── hello_world.swiftThe main application code is in Sources/hello-world/hello_world.swift.
Running Your Application
You have two options to run your Swift application:
Option 1: Using Swift Directly
Run your application locally using the Swift Package Manager:
swift runYou should see output similar to:
Building for debugging...
[8/8] Applying hello-world
Build of product 'hello-world' complete! (1.93s)
Hello, world!Option 2: Using Wendy CLI
Run your application using the Wendy CLI:
wendy runYou should see output similar to:
swift run
Building for debugging...
[8/8] Applying hello-world
Build of product 'hello-world' complete! (1.93s)
Hello, world!Understanding the Code
The generated hello_world.swift file contains a simple Swift program:
@main
struct HelloWorld {
static func main() {
print("Hello, world!")
}
}This is the entry point for your WendyOS application. The @main attribute marks this as the main entry point, and the main() function is called when the application starts.
Verifying Deployment on Your Device
After deploying your application to a WendyOS device, you can verify it was successfully deployed and ran by listing the applications on your device:
wendy device apps listYou should see output similar to:
wendy device apps list
✔︎ Searching for WendyOS devices [5.1s]
✔︎ Listing applications: WendyOS DeviceThis confirms that your Hello World application has been successfully deployed and is running on your WendyOS device.
Next Steps
Now that you have a basic Swift application running:
- Learn how to deploy your app to a WendyOS device
- Explore WendyOS frameworks for hardware access
- Build more complex applications with user input and data processing
Local Development: Both swift run and wendy run compile and run your application locally on your development machine. To deploy to a WendyOS device, you'll need to use wendy deploy.