parse-community / Parse-Swift

The Swift SDK for Parse Platform (iOS, macOS, watchOS, tvOS, Linux, Android, Windows)
https://parseplatform.org
MIT License
304 stars 69 forks source link

Request: Make backingStore optional rather than force unwrapped #444

Open alessdiimperio opened 11 months ago

alessdiimperio commented 11 months ago

New Feature / Enhancement Checklist

Current Limitation

when launching tests one doesn't necessarily want the entire app and all it's dependencies setup and initialized. So if we are running tests we generally skip certain setup functions.

However after migrating to ParseSwift from the ObjC SDK i realized that we were getting crashes only when testing. The reason for the crash was calling Installation.current which returns an optional Installation. However the backingStore is force unwrapped so even though the value is optional the underlying force unwrapped store crashes. Note the cause is that we don't initialize parse when running tests.

if the backingStore was optional instead of force unwrapped it wouldn't crash but instead just return nil.

Feature / Enhancement Description

change ! to ? and allow for the backingStore to be optional rather than force unwrapping it. at worst you'll have to add a few ? here and there but will allow for returning an optional value where an optional value is to be returned.

Example Use Case

running tests without having to initialize all dependencies

Alternatives / Workarounds

🤷

3rd Party References

force unwrapping is 👿 no bueno :P

parse-github-assistant[bot] commented 11 months ago

Thanks for opening this issue!

alessdiimperio commented 11 months ago

https://github.com/parse-community/Parse-Swift/pull/445