Skip to content

Starter Template

Vinícius Costa edited this page Apr 12, 2026 · 2 revisions

This page documents a minimal starter layout you can publish directly to GitHub.

Goals of the starter

The template is intentionally small, but still includes enough structure to be useful:

  • Swift Package project
  • minimal multi-window app
  • sidebar navigation via FlatNavigation
  • sample alert with text input
  • helper scripts for macOS, Linux, and Windows

Suggested repository layout

AparokshaStarter/
├── Package.swift
├── README.md
├── .gitignore
├── scripts/
│   ├── run-linux.sh
│   ├── run-macos.sh
│   └── run-windows.ps1
└── Sources/
    └── AparokshaStarter/
        └── main.swift

Suggested Package.swift

// swift-tools-version: 6.0
import PackageDescription

let package = Package(
    name: "AparokshaStarter",
    platforms: [
        .macOS(.v13)
    ],
    products: [
        .executable(name: "AparokshaStarter", targets: ["AparokshaStarter"])
    ],
    dependencies: [
        .package(url: "https://git.aparoksha.dev/aparoksha/aparoksha", branch: "main")
    ],
    targets: [
        .executableTarget(
            name: "AparokshaStarter",
            dependencies: ["Aparoksha"],
            path: "Sources/AparokshaStarter"
        )
    ],
    swiftLanguageModes: [.v5]
)

Suggested main.swift

import Aparoksha

@main
struct AparokshaStarter: App {

    let app = Aparoksha(
        id: "com.example.aparokshastarter",
        name: "Aparoksha Starter",
        settings: "Settings",
        about: "About Aparoksha Starter",
        developer: "Your Name",
        version: "0.1.0",
        quit: "Quit Aparoksha Starter",
        website: .init(string: "https://github.com/your-user/aparoksha-starter")!,
        websiteLabel: "Repository",
        issues: .init(string: "https://github.com/your-user/aparoksha-starter/issues")!,
        issuesLabel: "Issues",
        services: "Services"
    )
    .hideMenu(
        hideApp: "Hide Aparoksha Starter",
        hideOthers: "Hide Others",
        showAll: "Show All"
    )

    var scene: Scene {
        Window("Aparoksha Starter", icon: .headphones, id: "main") {
            ContentView()
        }

        Window("About Demo", icon: .headphones, id: "about-demo") {
            Text("This is a secondary window.")
                .padding(12)
        }
        .frame(width: .constant(360), height: .constant(220))
    }
}

struct ContentView: WindowView {

    @State private var selectedItem: SidebarItem = .home
    @State private var showAlert = false
    @State private var projectName = "Aparoksha Starter"

    var view: Body {
        FlatNavigation(SidebarItem.allCases, selection: $selectedItem) {
            switch selectedItem {
            case .home:
                VStack {
                    Text("Welcome to \(projectName)")
                        .padding(10)

                    Button("Rename project") {
                        showAlert = true
                    }
                }
                .padding(20)

            case .samples:
                VStack {
                    Text("Add your sample views here.")
                        .padding(10)
                }
                .padding(20)
            }
        }
        .alert(
            visible: $showAlert,
            title: "Rename project",
            content: "Enter a new display name below.",
            closeLabel: "Cancel"
        ) {
            print("Alert closed")
        }
        .primaryResponse("Save", style: .suggested) {
            print("Saved name: \(projectName)")
        }
        .textField("Project name", text: $projectName)
    }
}

enum SidebarItem: String, FlatNavigationItem, CaseIterable, Equatable, Codable {
    case home
    case samples

    var id: Self { self }

    var description: String {
        rawValue.capitalized
    }

    var icon: Icon {
        switch self {
        case .home:
            return .navigation
        case .samples:
            return .warning
        }
    }
}

Helper scripts

scripts/run-macos.sh

#!/usr/bin/env bash
set -e
APAROKSHA_FRAMEWORK=APPKIT swift run AparokshaStarter

scripts/run-linux.sh

#!/usr/bin/env bash
set -e
APAROKSHA_FRAMEWORK=ADWAITA swift run AparokshaStarter

scripts/run-windows.ps1

$env:APAROKSHA_FRAMEWORK = "WINUI"
swift run AparokshaStarter

What to customize first

Start by updating these values in main.swift:

  • app id
  • app name
  • repository URL
  • issues URL
  • developer name
  • version
  • sidebar pages
  • actual app views

Publish to GitHub

git init
git add .
git commit -m "feat: add initial Aparoksha starter template"

After that, create the GitHub repository and push normally.