Building a Virtual Machine App on MacOS: Part 3

30-03-2025

Last time, I implemented the MVVM architecture, which made it a breeze this week to add a CRUD system for saving virtual machine configurations. I started by looking into different data storage options and found a few possibilities:

  • Backend as a Service (Firebase, Supabase, etc.) – These are great for remote data access, but since this app doesn’t need cloud storage, I decided to skip them.
  • UserDefaults – Perfect for storing small user preferences or settings, but not ideal for saving virtual machine data. However, I might use it later for app settings.
  • Plist (Property List) – Useful for structured data like configuration files and preferences. I tried it out, and it worked well, but it wasn’t the right fit for my needs.

After testing these options, I decided to use SwiftData. I first heard about it at a WWDC presentation and liked the idea, but I hadn’t found a use case for it until now. SwiftData is easy to use, making it a great choice for local data storage.

While using SwiftData, I ran into a couple of issues:

  1. MVVM Compatibility – SwiftData isn’t built specifically for MVVM, which caused some integration problems. After some research, I found that adding a service layer helped bridge the gap
  2. Model Issues – I got an error related to mismatched types. Debugging revealed that an enum inside my model was missing the Codable protocol. Adding it fixed the issue.

Once these problems were fixed, implementing CRUD operations was a breeze.

This time I was really productive, as I explored different storage options and successfully integrated local data persistence. Next time, I’m excited to dive into the different virtual machine options available in the Virtualization framework.