Thoughts, reflections, and ideas

Rewriting SugarRecord, 2.0

Posted on

SugarRecord is one of the libraries I'm most proud of. It has currently 1.155 favs and 98 forks on Github and a couple of issues opened. I wrote this library when the first version of Swift was released since I wanted to learn the language and I thought that writing a library could be a great idea for learning.

SugarRecord 1.x, suffering Swift evolution

Swift changed very fast with every new version, moreover we didn't have CocoaPods support yet so all the integration steps were manual. Realm was still giving its first steps and my knowledge about CoreData was quite limited. I had used MagicalRecord and I used it as inspiration to implement the Swift equivalent. The structure was quite similar but taking advantage of Swift features like generics. One of the most difficult things by that time was designing an abstraction layer that could wrap both, Realm and CoreData simultaneously. The interface of Realm was much more fresh than CoreData and I was trying a to achieve a similar approach with SugarRecord.

The power of CoreData and Realm but with a nice to use interface.

I released the first version of SugarRecord and kept updating and adding new features according to developers requests. However, a few months later I had to left the project because I didn't have enough time to invest, I spent most of my time with my full-time job and I was simultaneously working on another project in my free time. I tweeted if someone could be interested in continuing with the project and make it a great reference in the Swift community. With some help a few versions were launched after I abandoned the project but there was a lack of motivation in the team that handed-over the project and it remained outdated for some months. Developers started forking, solving the bugs on their own repositories, and some amount of issues opened in the repository increased.

Swift 2.0, time to update

I still had the SugarRecord account active and I saw how people were tweeting about SugarRecord and reporting issues on Github. Swift 2.0 was launched by that time and people were asking for support for that new version. SugarRecord was completely broken in that version and people needed a new version of SugarRecord for their Swift 2.0 projects.

"I born that project and helped it growing, couldn't leave it abandoned" I thought, and then took the decision to start working in SugarRecord 2.0. Here's the tweet I published notifying the developers that the next version was in the oven:

I decided not to continue with the same codebase which was strongly inspired in MagicalRecord but starting from the scratch. Take all the good practices, new Swift 2.0 features, and problems that developers reported with the previous version and try to do something better, more robust, safe and actively supported. I started working on it. It was a few months of development since I didn't have much time, but I was able to finish it and publish the first version of SugarRecord 2.0 whose features are listed below:


Things learned with SugarRecord

With SugarRecord it's the first time I see someone creating an issue that starts with I need an example project....... It made me feel like a servant.

SugarRecord is available for your Swift projects. If you don't want to save time setting up your CoreData/Realm stack, you can use it. I'm also looking for contributors that want to contribute with the project, help fixing bugs, adding new features, and definitively making SugarRecord better every day. If you're interested, drop me a line [email protected]