Open Source Adventures #5 - SwiftyUserDefaults

May 14, 2019 17:11 · 5 minute read #open-source #swift #swiftyuserdefaults

tl;dr
Radek asking for help Sliding into Radek's DMs
pls read full version below

2018

I’ve been an avid user of SwiftyUserDefaults since its release. Always wanted to help out, but somehow I didn’t have a chance to do so. But, when Radek asked if someone could help him out in these dark times, I didn’t think twice. This was my chance to support him and the library that I used a lot.

I’ve got my hands on the project in early February. First thing I noticed was a lot of issues and pull requests - some of them were outdated, some duplicated and some not even related to the library. I spent the next few days on cleaning them up and creating a community wishlist for the upcoming version of the library. I’ve made an issue on GitHub repository to update everyone on the status of the project.

Version 4.0.0 draft

I knew that the library had to be rewritten to achieve what I’ve planned. And so, the next few weeks I was playing with SwiftyUserDefaults’s internals to understand the reasoning behind some of the design decisions. For instance, there is a reason why we don’t use userDefaults.bool(forKey:) but a little bit more tangled fetching method. Thanks to that I was able to rewrite the library, add new features and still keep the API intact. First alpha of the library was then released.

First alpha of version 4

Why alpha and not beta? This is because the rewrite was really big and I didn’t want to promise only non-breaking changes.

At this point everything was going great. I tested both the old and the new version to make sure they are compatible with each other. I tested the library in a big, commercial product to confirm it has all it needs. I added a big test suite to cover all the use cases I found in the previous version. All of these to make sure I do not break anything and to have a safety net for new contributors (and myself). Unfortunately, it wasn’t enough.

Few weeks after the initial release we’ve got a question about the new version and its usage.

Question: How to support non-final classes with version 4?

Turns out this was a use-case I didn’t catch. Due to some limitations in generics (and probably my poor understanding of these issues), the library wasn’t able to support non-final classes - and it’s a pretty big hit when you consider that you wouldn’t be able to use UIColor (and more Obj-C non-final classes) with SwiftyUserDefaults.

I spent weeks and months tackling this problem from multiple angles, but ultimately, with the way I designed the rewrite, I wasn’t able to make it work. It was already few months after the release of the first alpha and I didn’t know what to do. At that time I was also having troubles with Harvey (see OSS#4 if you haven’t already) so I was really not in a good shape. I’ve reached out for help to a few friends of mine and some SwiftyUserDefaults contributors/users.

Asking for help on GitHub issues.

Unfortunately, not many people did respond. And the ones who did couldn’t find a solution. And so I wrote a message to Radek explaining the situation and pointing out two potential solutions:

  • spend some more time and maybe fix the underlying problem
  • just release a really small update that would only add Swift 4 support (library should be running Swift 4 months ago)

We agreed with Radek that we should both try to solve the problem first and then, if we didn’t found a solution fast enough, just fallback to the Swift 4 update. Guess what happened?

2019

We failed. I failed. I couldn’t find a solution. And I didn’t have the guts to let down all these people waiting for an update. Not sure why, but I think I had some sort of a brainfart and I thought that I owe the users the best they can get. I didn’t think once about me. And so I burned out and disappeared for a few months…

… to come back in late January, 2019. The break did help me a lot, though. I was refreshed, my mind was a lot healthier and I was eager to finalize what I’ve started with SwiftyUserDefaults in 2018. I’ve updated the GitHub issue again.

2019 update comment on GitHub issue.

I planned to play with the library one last time and see if I could tackle the problem with a fresh pair of eyes.

I sat down with a cup of coffee on a beautiful, Saturday morning and I was ready to dive into it again. I spent all day trying different approaches but again, I didn’t succeed. However, something felt different. I could sense the solution in the air, I just didn’t know how to catch it. And then it happened.

(By the will of the Swift gods) I’ve managed to design a new core of the library and, this time, with the support of non-final classes. This was one of these moments that help me go through all of this. The pure joy of squeezing everything so people can enjoy their day. That spark in me also implemented five more features that I didn’t even consider for the initial release. And then I released a new alpha (btw first time in my life I had to do a migration guide from alpha.1 to alpha.2 😅).

SwiftyUserDefaults 4.0.0-alpha.2 released!

Finally, after many months of testing, version 4.0.0 was officially released.

SwiftyUserDefaults 4.0.0-alpha.2 released!

If you’re interested in the changelog, see this blog post.

The project, as of now, is in a great shape. Awesome CI setup, testing suite and, of course, features. If you’re interested in getting excited about Open Source, SwiftyUserDefaults could be a great starting point. There are lots of features that could still be added to the library. And I can guide you through every step - if you want of course.



share:

Comments