# How to Find the Main Entry Point of the Palmier Pro Application

> Locate the main entry point for the Palmier Pro application in main.swift. Discover how the application bootstraps NSApplication and manages its lifecycle.

- Repository: [Palmier/palmier-pro](https://github.com/palmier-io/palmier-pro)
- Tags: internals
- Published: 2026-06-30

---

**The main entry point of Palmier Pro resides in [`Sources/PalmierPro/App/main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/main.swift), which bootstraps the `NSApplication` instance and delegates lifecycle management to [`AppDelegate.swift`](https://github.com/palmier-io/palmier-pro/blob/main/AppDelegate.swift).**

Palmier Pro is a macOS application built with Swift and AppKit, following the conventional Cocoa bootstrap pattern. Understanding where execution begins is essential for debugging startup issues, modifying initialization behavior, or contributing to the `palmier-io/palmier-pro` repository. The application uses the standard macOS flow where the `main` function creates an `NSApplication` before handing control to an application delegate.

## Locating the Primary Entry Point

The absolute starting point of any Swift macOS application is the file containing the top-level code that executes first. In Palmier Pro, this responsibility belongs to a single file in the App subdirectory.

### The main.swift Bootstrap Sequence

In [`Sources/PalmierPro/App/main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/main.swift), the runtime executes a series of setup calls before starting the application run-loop. This file contains the process entry point where the `NSApplication` instance is configured and launched:

```swift
import AppKit

Log.bootstrap()
Telemetry.start()
BundledFonts.register()
AccountService.shared.configure()
ModelCatalog.shared.configure()

UserDefaults.standard.set(10, forKey: "NSInitialToolTipDelay")

let app = NSApplication.shared
let delegate = AppDelegate()
app.delegate = delegate
app.mainMenu = MainMenuBuilder.buildMenu()
app.run()

```

The final line `app.run()` starts the Cocoa run-loop, at which point the operating system begins sending lifecycle events to the delegate.

### The AppDelegate Lifecycle Handler

Once the application object initializes, it forwards critical launch events to [`Sources/PalmierPro/App/AppDelegate.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/AppDelegate.swift). This class conforms to `NSApplicationDelegate` and implements `applicationDidFinishLaunching(_:)` to complete the startup sequence:

```swift
final class AppDelegate: NSObject, NSApplicationDelegate {
    func applicationDidFinishLaunching(_ notification: Notification) {
        NSApp.setActivationPolicy(.regular)
        NSApp.activate(ignoringOtherApps: true)

        // Start Sparkle updater
        _ = Updater.shared

        HomeWindowController.shared.showWindow(nil)
        // …additional startup logic…
    }
    // …
}

```

This delegate method activates the app, initializes the Sparkle update framework via `Updater.shared`, and displays the initial window through `HomeWindowController.shared.showWindow(nil)`.

## Running the Application from Source

To execute the entry point locally and observe the bootstrap process, use the Swift Package Manager from the repository root:

```bash
swift run

```

This command compiles the target and executes the `main` function defined in [`Sources/PalmierPro/App/main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/main.swift), triggering the full initialization sequence including logging setup, telemetry configuration, and main menu construction.

## Key Files in the Startup Architecture

Understanding the relationship between these components clarifies how execution flows from process launch to user interface:

- **[`Sources/PalmierPro/App/main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/main.swift)** – Contains the top-level entry point that instantiates `NSApplication.shared`, assigns the `AppDelegate`, builds the main menu via `MainMenuBuilder.buildMenu()`, and calls `app.run()`.
- **[`Sources/PalmierPro/App/AppDelegate.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/AppDelegate.swift)** – Implements `NSApplicationDelegate` to handle `applicationDidFinishLaunching`, initializing services like the Sparkle updater and displaying the primary window.
- **[`Sources/PalmierPro/App/MainMenu.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/MainMenu.swift)** – Constructs the application's menu bar (referenced within [`main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/main.swift) through `MainMenuBuilder`).

## Summary

- The **process entry point** resides in [`Sources/PalmierPro/App/main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/main.swift), where the `main` function initializes logging, telemetry, and the `NSApplication` instance.
- **Lifecycle management** is delegated to [`Sources/PalmierPro/App/AppDelegate.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/AppDelegate.swift), which handles post-launch initialization including window creation and service startup.
- **Execution begins** with `app.run()` in [`main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/main.swift) and transitions to `applicationDidFinishLaunching(_:)` in the delegate.
- **Local execution** is triggered via `swift run`, which compiles and invokes the entry point automatically.

## Frequently Asked Questions

### Where exactly is the main function defined in Palmier Pro?

The `main` function is implicitly defined in [`Sources/PalmierPro/App/main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/main.swift) through top-level executable statements. This file serves as the process entry point where the `NSApplication` instance is created and the run-loop starts via `app.run()`.

### What initialization happens before the app window appears?

Before displaying the initial window, the application executes `Log.bootstrap()`, `Telemetry.start()`, `BundledFonts.register()`, and configures both `AccountService` and `ModelCatalog` within [`main.swift`](https://github.com/palmier-io/palmier-pro/blob/main/main.swift). Subsequently, `AppDelegate.applicationDidFinishLaunching(_:)` initializes the Sparkle updater and instantiates `HomeWindowController` to display the interface.

### How do I modify the startup behavior or initial window?

To alter startup behavior, edit [`Sources/PalmierPro/App/AppDelegate.swift`](https://github.com/palmier-io/palmier-pro/blob/main/Sources/PalmierPro/App/AppDelegate.swift) and modify the `applicationDidFinishLaunching(_:)` method. To change which window appears first, replace the `HomeWindowController.shared.showWindow(nil)` call with your custom window controller or view controller presentation logic.

### Is Palmier Pro built with SwiftUI or AppKit?

According to the source code in `palmier-io/palmier-pro`, the application uses **AppKit** (`import AppKit`) rather than SwiftUI. It follows the traditional Cocoa architecture with `NSApplication`, `NSApplicationDelegate`, and `NSWindowController` subclasses for window management.