From Idea to App in a Day: How I Built a macOS Productivity Tool with an AI Pair Programmer
Have you ever had an idea for a simple app, something to scratch a personal itch, but the thought of setting up a project, writing boilerplate code, and wrestling with APIs made you push it to the "someday" pile? I've been there. But recently, I decided to see if I could bring one of these ideas to life with the help of an AI large language model as my pair programmer. The result? A fully functional macOS status bar application for tracking my daily context switches, built from scratch in a single day.
## The Spark of an Idea
My request was simple: a macOS app that lives in the status bar. I wanted a counter that I could manually increment every time I got distracted and switched away from focused work. The counter should reset daily, and I wanted to see a history of my context switches in a bar chart to visualize my focus patterns.
The AI immediately laid out a clear plan: a Swift and SwiftUI application, data stored locally in a JSON file, and a status bar icon that would serve as the main interface. Within minutes, it had initialized a Swift project and started writing the code.
## Building the Foundation and Hitting the First Snags
The initial development was a whirlwind. The AI generated the code for the main application delegate, a `DataStore` class to handle reading and writing the JSON data, and a SwiftUI view for the bar chart. It was impressive to see the project structure come together so quickly.
However, the first build attempt failed. A classic Swift error: a conflict between the `@main` attribute and top-level code in `main.swift`. This is where the "pair programming" aspect really shone. I pointed out the error, and the AI, after a few attempts, correctly identified the issue and refactored the code to resolve the conflict. It was a reminder that even with a powerful AI, the development process is still one of trial and error.
## Iterating on Features and UI
With the app running, we moved on to adding features. I requested a way to clear the test data, and the AI added a "Clear Data" menu item with a confirmation dialog to prevent accidental deletion. We then tackled the user interface, making the chart window float so it wouldn't get lost behind other windows, and then enhancing the chart itself with a horizontal scroll view, gradients, and animations to make it more visually appealing.
One of the most interesting parts of the process was creating the application icon. The AI guided me through the process of creating an `.icns` file from a PNG, including the command-line fu to generate all the required sizes. We hit a few snags with the status bar icon, which initially appeared as a black rectangle. After a few failed attempts to use a custom image, we settled on using a built-in SF Symbol, which is the standard practice for modern macOS apps and ensures the icon looks great in both light and dark mode.
## From Simple Counter to Insightful Tracker
The real power of the app came from a new feature I requested: tracking the time *between* context switches. This would give me a much better understanding of my focus intervals. The AI refactored the `DataStore` to save timestamps for each switch, and then created a new bar chart to visualize the distribution of time intervals (e.g., "<1 min", "1-5 min", "5-15 min", etc.). This transformed the app from a simple counter into a genuinely insightful productivity tool.
Of course, this new feature introduced new bugs. The app would crash if you opened and closed the chart window twice in a row, and for a while, closing the chart would quit the entire application. Each time, I'd describe the problem, and the AI would propose a solution, which we'd then implement and test. We eventually landed on a stable solution where the chart window is hidden rather than closed, a common pattern in macOS development.
## The Final Product and Reflections
In the end, I had a polished, functional, and useful application. The entire process, from the initial idea to the final commit, took just a single day. The experience of pair programming with an AI was fascinating. It was incredibly fast at generating code and implementing new features, but it still required human guidance to navigate the nuances of the macOS SDK, debug subtle issues, and make design decisions.
This project was a powerful demonstration of how AI can accelerate the development process, turning what might have been a week-long project into a single day's effort. It's a glimpse into the future of software development, where the synergy between human creativity and artificial intelligence will allow us to build and iterate on our ideas faster than ever before.
Disclaimer: 100% AI generated content. The human written version is here.
Comments
Post a Comment