I've already searched extensively on Apple Developer Forums and Stack Overflow, and didn't really find what I need or I missed it.
I'm developing a macOS music player app that uses cuesheet files paired with audio files. The core functionality is working, opening and playing files works without issues, but I'm struggling with implementing proper file handling features due to my limited experience with UI frameworks.
The current state of my app is intentionally simple:
- Single window interface representing a music player with track list
- Opening cuesheet files changes the “disc” and updates the window
- Built with SwiftUI (not AppKit)
- Not created as a Document-Based app since the user doesn't need to edit, save, or work with multiple documents simultaneously
What I Need to Implement:
- Open Recent menu that actually works
- Recent files accessible from Dock menu
- Opening cuesheet files from Finder
- Drag-and-drop cuesheet files onto app window (lower priority)
Problems I've Encountered:
I've tried multiple approaches but never achieved full functionality. The closest I got was an “Open Recent” menu that:
- Only updated after app relaunch
- Its drop-down kept closing while music was playing
My Questions
- Is it possible purely in SwiftUI?
- Is there documentation I'm missing? I feel like I might be overcomplicating this.
I'm open to alternative approaches if my current direction isn't ideal:
- Should I redesign as Document-Based? Since I apparently need NSDocumentController, would it be better to start with a Document-Based app template and disable unwanted features, and how?
- Should I mix AppKit with SwiftUI? While SwiftUI has been wonderful for my main window, it's becoming frustrating for other UI parts, especially menus. Would using AppKit for menus and keeping SwiftUI for the main interface be a reasonable approach?
I thought this would be straightforward:
- Customize the .fileImporter with the proper logic of what to do with the files
- Call NSDocumentController.shared.noteNewRecentDocumentURL(url) so the Open Recent menu is created a populated with opened files.
Maybe it really is that simple and I've gotten lost down a rabbit hole? UI programming is quite new to me, so I might be missing something obvious.
Any guidance, code examples, or pointing me toward the right documentation would be greatly appreciated!