47nil

Updates On The App

If you remember, I gave myself some design / software rules that I needed to follow. Those rules led me to investigate a few things that I didn’t know much about, like security and data synchronization. I’m happy with all the new things I’m learning.

So, here’s what happened this week. I was writing the bulk of things in Go, since it has a powerful way of supporting several operating systems, and it’s relatively straightforward. However, I’ve noticed a high CPU utilization while performing data loading and synchronization. I tested this and yes, while running on a less powerful piece of hardware (a Raspberry Pi), the process was painfully slow.

I’m still trying to figure out where exactly the issue is, but my gut is telling me that the processing of large JSON objects is the culprit, so I’m reassessing how those are created, opened, loaded and saved. The issue becomes evident when the sync process happens at the same time of the large write to local files.

Again, the idea is to save all data locally, and sync it across multiple devices only if necessary. This will prevent the data from being held captive by a service that might go down or cease to exist, and support a more private world, where your data is yours to keep and manage.

We will see how I fix this. I’m asking a few friends with data and computing experience.

The other issue I ran into is how much I hate Swift and SwiftUI for MacOS, iOS, and iPadOS app development.

Yes, I use the word hate. What the fuck Apple?

On the one hand it’s great that with a few lines of code you can create a beautiful user interface (UI), but on the other hand, anything that is not a UI is almost impossible to get right off the bat. The amount of hacks and loading of older frameworks that still need to be done to get anything to work is mind numbing.

But let’s go back to the problem at hand: loading local files and displaying the data loaded after being read from a JSON-formatted file. With Swift this is a pretty straightforward action, where you call a few functions, save the data read into a struct that has the same format as the JSON object data, and off you go.

Yes, but...

Due to the current security model that Apple is pushing for all its devices, specially the Macs, it’s really hard for an application developed for this platform using Swift/SuiftUI to be able to save a file randomly on disk. So, when I first launch the application and I see that this is the first run, I try to create a default directory where the local data would be stored. Or, if a directory with that name, containing JSON files already exists, I try to open that directory, load each file, and display the data. However, this is not possible because, unless the user purposely authorizes the opening or a file, or the reading of a specific directory outside a very minimal collection of authorized directories, I would always get an error permission denied when trying to access those files.

The workaround is to ask the user to pick a location to save the default files, which isn’t that bad, as UX, but the next time the user opens the application, you would expect those files to be able to be accessed without issues, but no. More permission denied. I found a hacky workaround, but this is annoying as fuck! Simple file load/save is just impossibly hard. Not to mention you need to use a whole different collection of frameworks to be able to use functions to read files, even from plain text ones. The functions are so impossibly obtuse and complicated in their syntax that I wonder if I should just go back to good ol’ Objective-C and call it a day. Harder on the UI building, but so much easier on everything else...

Anyway, fun problems to have. It’s keeping me busy, which I like.

The challenge is on!