Weeks updated to version 3.0

A few years ago while learning about macOS app development, I created a small utility app as an exercise. A tiny app that shows the current week number in the menu bar. It's available in the macOS App Store.

Since its release a few years ago, I've only done a few minor updates, but the operating system has changed a lot. This caused a lot of issues for the app. It would no longer auto launch on login, and it wouldn't update if it was running while a new week started.

This new version is written from scratch using SwiftUI, and fixes all of those problems, and has a new icon to match the Big Sur style.

As a side note for those interested, during the experimentation with SwiftUI, I learnt a hack that makes it possible to create a App using WindowGroup{}, but with a hidden window on launch.

@main struct WeeksApp: App {
  @Environment(\.scenePhase) private var scenePhase

  var body: some Scene {
    WindowGroup { Optional(EmptyView()) }
    .onChange(of: scenePhase) { phase in
      switch phase {
      case .background:
        print("Background")
      case .active:
        print("Active")
      case .inactive:
        print("Inactive")
      @unknown default:
        fatalError()
      }
    }
  }
}

Hopefully WWDC 2021 will have a better story for this. This code still produces a window in the view hierarchy, it just is hidden for the user.

[1] Weeks in the macOS App Store