sunshinejr / SwiftyUserDefaults

Modern Swift API for NSUserDefaults
http://radex.io/swift/nsuserdefaults/static
MIT License
4.85k stars 366 forks source link

Version 4.0.0 #154

Closed sunshinejr closed 5 years ago

sunshinejr commented 6 years ago

Hey guys! Recently I've taken over the maintenance of SwiftyUserDefaults and I'm here to say that we are in the process of a big update. I started with the basics first:

Currently I'm working on the newest version that should include few big changes:

There are many more features that I would like to implement, but I just want to give you something as soon as possible. And I think that this is the core that you'll guys like (based on the feedback).

It's not finished yet, but I'd expect to see a beta in the upcoming weeks. I will be also looking for options to get version for Swift 4.0/4.1 separately if possible, but conditional conformance from 4.1 might change things.

Also @radex will be helping me in the first alpha phase to make sure we are on the right track. After that we will start a public beta so you could give us your feedback as well.

I'll be updating the status of the release in this topic.

Cheers! 🌞

sunshinejr commented 6 years ago

Hey guys! So this week I'm planning to show you the first preview of the 4.0.0-alpha version! Currently, I have a working copy of the next version - all of the features I listed are in, but with some rough code in it. Let's hope that all of these will work after the cleanup πŸ˜‰

The update took longer than expected because of the Codable support with the default values and generic subscripts with statically typed initializers altogether. It was really not easy to come up with the solution that had it all. Basically, we can't really extend Codable to implement a certain protocol. This way we would have to think about a way of creating a DefaultsKey from two different protocols (or even better, for Codable, DefaultSerializable - which is a custom way of storing/getting the value from UserDefaults and Codable & DefaultsSerializable at once). And I didn't want to make a big migration, but rather keep the existing functionality and add on top of that.

Thus, the solution I came up with was to use two classes for DefaultsKey: DefaultsKey, the backwards-compatible version that you use today, and DefaultsCodableKey, a class specialized for Codable serializing. There will be some additional protocols so you can extend any type you want to have a defaultValue or fetch/store a value to UserDefaults your way.

See all the new options are in the screen below. Personally, I love that when you want to initialize a key without a default value either by parameter or a type, you'll get an instant error about it πŸ˜‰

zrzut ekranu 2018-04-30 o 22 59 34

* Note: All the protocol names are WIP, might change in the future.

sunshinejr commented 6 years ago

WIP is already there: #155! πŸŽ‰

sunshinejr commented 6 years ago

4.0.0-alpha.1 released! πŸŽ‰ Please try it out and let me know how it feels (as we still have time for improvements πŸ˜…)!

annawidera commented 5 years ago

Hello @sunshinejr :) Are there any list of things that need to be done / fixed / checked before leaving the alpha stage? :) There are couple of PRs hanging as well. Are there anything you guys need help with? I would love to use SwiftyUserDefaults with its ability to store Codable structs in UserDefaults but, please don't get me wrong, using alpha version in production code still feels quite hesitantly. Best! Ania

sunshinejr commented 5 years ago

Hey @annawidera, we were stuck on making classes work correctly with version 4.0.0. I was talking with Radek few months ago about it but I don't think we've found a solution for that (see #157 for tracking the problem).

We were thinking about rewriting SwiftyUserDefaults 4.0, without many new functionalities, but updated to support Swift 4.2+. I think it might be the best way for now, as we can't squeeze in the new features with current problems we have. Will give it another look next week or so again. Thanks for the ping!

sunshinejr commented 5 years ago

Happy to update you guys that version 4.0.0-alpha.2 has been released! We had to do a full rewrite, but I'm positive that we squashed all the major bugs we had in alpha.1. Please take a look at all the changes, migration guide from alpha.1 to alpha.2, and let me know your thoughts!

sunshinejr commented 5 years ago

4.0.0-alpha.3 was released as well with 2 bug fixes! Please try it out and let me know if anything else occurs.

sunshinejr commented 5 years ago

Another update! 🌞

I'm working on basic KVO wrapper and that will be the last feature that will go into beta, which will include:

If I'll have time I'm gonna try to squeeze basic multidimensional array support as well, but no promises on that one.

Beta should be released today or tomorrow.

sunshinejr commented 5 years ago

4.0.0-beta.1 released! πŸš€ In this one few cool additions:

DivineDominion commented 5 years ago

Anything else you need help with?

sunshinejr commented 5 years ago

@DivineDominion Hey Christian, first of all thank you very much for your help - I really appreciate that! πŸš€

In terms of a release, I was just waiting if there is any feedback on current version so I would have a better understanding about problems our users would encounter. As this was a big rewrite I've given it a bit more time than I usually do with betas.

About current pull requests, I think I'd only get #186 to the 4.0.0 version and then release a stable one. I want to release 4.0.0 with Swift version being 4.* as this is how beta's started and I don't want to make a breaking change and break semantic versioning.

Then we would iterate onto version 5.0.0 with Xcode 10.2/Swift 5 being the default and as an additional feature we would start with your PR with registering defaults.

Do you think this makes sense?

DivineDominion commented 5 years ago

Sounds reasonable. I'd argue that making defaultValue public is important, then, or else nobody can register defaults based on the current keys and would have to duplicate the key-value pairs on their end. Making it public is not a breaking change, so that should work.

The PR to register defaults more conveniently can wait until that's finished, I think.

sunshinejr commented 5 years ago

Version 4 has been officially released! Thanks all, hope you enjoy it and let us know how do you like it πŸš€