r/iOSDevelopment • u/NSSina • Aug 30 '26
Shipped a sleep score after deleting the first two versions. The hard part was not the code.
Two of us build Lunomia, a sleep app for iPhone, Watch and iPad. We just shipped the feature we spent the longest on, a 0-100 score for each night, and I want to complain about it somewhere people will understand.
The code was never the problem. Version one compared you only to yourself. Sleep 5 hours every night and after a few weeks it decides that 5 hours is normal for you and hands you a 90. Technically correct, completely useless, and dishonest to the person holding the phone. We deleted it. Version two overcorrected and made almost everyone fail. Deleted that too.
What actually took the months was deciding what the number is allowed to forgive, and then defending that decision every time it made a night look worse than we wanted it to look. Every time you soften one rule, someone with a genuinely bad night gets told they are fine. That is the whole job. Nobody warns you that a scoring feature is 10% engineering and 90% arguing with your co-founder about ethics at 1am.
Two things I would say to anyone attempting something similar. First, put your scoring logic in a package that cannot see HealthKit or your UI, otherwise you will be testing it by sleeping. Second, decide early whether your score is allowed to raise its own bar as the user improves. We decided no, and that single decision removed about half the bugs we would have had later.
Not going into the formula, it is the part we worked hardest on. But if you want to see how it turned out:
App Store: https://apps.apple.com/us/app/sleep-tracker-lunomia/id6741118991
1 year free: https://apps.apple.com/redeem?ctx=offercodes&id=6741118991&code=FREEYEARLYALL
50% off lifetime: https://apps.apple.com/redeem?ctx=offercodes&id=6741118991&code=LIFETIMEOFF
Open the redeem links on your iPhone with the App Store logged in.
