# FluidVoice macOS Application Entry Point: Located in fluidApp.swift

> Discover the FluidVoice macOS application entry point located in fluidApp.swift. Learn how the SwiftUI @main struct initializes services and hosts the main window.

- Repository: [ALTIC/FluidVoice](https://github.com/altic-dev/FluidVoice)
- Tags: internals
- Published: 2026-06-30

---

**The FluidVoice macOS application launches from the SwiftUI `@main` entry point defined in [`Sources/Fluid/fluidApp.swift`](https://github.com/altic-dev/FluidVoice/blob/main/Sources/Fluid/fluidApp.swift), where the `FluidApp` struct initializes global services and hosts the main window.**

The altic-dev/FluidVoice repository contains a SwiftUI-based macOS voice application. Understanding the FluidVoice macOS application entry point is essential for developers contributing to the codebase or debugging launch issues. The app follows modern Swift conventions, using the `@main` attribute to designate its starting point rather than the traditional [`main.swift`](https://github.com/altic-dev/FluidVoice/blob/main/main.swift) file.

## The @main Entry Point in fluidApp.swift

According to the FluidVoice source code, the application bootstrap begins in [`Sources/Fluid/fluidApp.swift`](https://github.com/altic-dev/FluidVoice/blob/main/Sources/Fluid/fluidApp.swift). This file contains the `FluidApp` struct marked with the `@main` attribute, which instructs the Swift compiler to generate the program's entry point.

```swift
@main
struct FluidApp: App {
    // ...
}

```

When the binary executes, the SwiftUI runtime calls the `init()` method of `FluidApp` before constructing the scene hierarchy defined in the `body` property.

## Initializing Global Services and UI

Inside the `FluidApp` struct, the initializer sets up the global state objects that persist throughout the application lifecycle.

### Injecting the AppServices Singleton

The entry point instantiates the shared service container immediately upon launch:

```swift
init() {
    // Use the shared singleton instance
    _appServices = StateObject(wrappedValue: AppServices.shared)
}

```

This injection makes `AppServices` available to the entire view hierarchy through SwiftUI's environment object pattern.

### Constructing the Window Group

The `body` property defines the top-level scene that macOS displays on startup:

```swift
WindowGroup(id: "main") {
    AdaptiveAppTheme(accent: self.settings.accentColor) {
        ContentView()
            .environmentObject(self.menuBarManager)
            .environmentObject(self.appServices)
    }
}

```

This configuration creates the main window with `ContentView` as the root, immediately injecting the `MenuBarManager` and `AppServices` dependencies required for the menu bar and background operations.

## AppDelegate Lifecycle Integration

While [`fluidApp.swift`](https://github.com/altic-dev/FluidVoice/blob/main/fluidApp.swift) serves as the true entry point, FluidVoice also attaches an `AppDelegate` to handle macOS-specific lifecycle events:

```swift
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

```

The `AppDelegate` receives callbacks such as `applicationDidFinishLaunching`, where it performs early initialization including logging setup, update checks, and launching the local API server. However, this delegate is secondary to the `@main` struct that triggers the initial process creation.

## Minimal Entry Point Example

To replicate the FluidVoice launch structure in a new macOS SwiftUI project, implement the following pattern:

```swift
import SwiftUI

@main
struct FluidApp: App {
    @StateObject private var menuBarManager = MenuBarManager()
    @StateObject private var appServices = AppServices.shared
    @ObservedObject private var settings = SettingsStore.shared
    @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    var body: some Scene {
        WindowGroup {
            ContentView()
                .environmentObject(menuBarManager)
                .environmentObject(appServices)
        }
    }
}

```

This structure ensures proper service initialization before the first view renders.

## Testing the Application Entry Point

You can verify the entry point behavior in unit tests by instantiating the `@main` struct directly:

```swift
import XCTest
@testable import Fluid

final class LaunchTests: XCTestCase {
    func testAppStarts() {
        // Instantiating the @main struct triggers the launch.
        let _ = FluidApp()
        XCTAssertTrue(AppDelegate.sharedDidLaunch) // custom flag you could add for testing.
    }
}

```

## Summary

- The FluidVoice macOS application entry point is located in [`Sources/Fluid/fluidApp.swift`](https://github.com/altic-dev/FluidVoice/blob/main/Sources/Fluid/fluidApp.swift) via the `@main` attributed `FluidApp` struct.
- The `init()` method instantiates `AppServices.shared` as a `StateObject` before the UI appears.
- `WindowGroup` hosts `ContentView` as the root view, injecting environment objects for the menu bar and global services.
- `AppDelegate` handles platform-specific launch callbacks but is attached via `@NSApplicationDelegateAdaptor` rather than acting as the primary entry point.

## Frequently Asked Questions

### What file contains the main entry point for FluidVoice?

The main entry point is defined in [`Sources/Fluid/fluidApp.swift`](https://github.com/altic-dev/FluidVoice/blob/main/Sources/Fluid/fluidApp.swift). This file contains the `FluidApp` struct marked with `@main`, which the Swift compiler uses to generate the executable's entry point.

### How does FluidVoice initialize its global services at launch?

Inside the `FluidApp` initializer, the code creates a `StateObject` wrapped around `AppServices.shared`. This singleton pattern ensures that global services like audio processing and API management are available immediately when the app launches and persist throughout the session.

### Can I use AppDelegate with SwiftUI's @main entry point?

Yes. FluidVoice uses the `@NSApplicationDelegateAdaptor` property wrapper to attach an `AppDelegate` to the SwiftUI app lifecycle. This allows the app to receive traditional macOS lifecycle callbacks such as `applicationDidFinishLaunching` while maintaining the modern `@main` entry point structure.

### Where does FluidVoice create its main window?

The main window is defined in the `body` property of the `FluidApp` struct within [`fluidApp.swift`](https://github.com/altic-dev/FluidVoice/blob/main/fluidApp.swift). It uses a `WindowGroup` containing `ContentView` as the root view, wrapped in an `AdaptiveAppTheme` that applies the user's accent color settings.