What is different ?
This week, I want to share a fascinating debugging story from our work at Klivvrโ that illustrates a powerful troubleshooting technique I call 'What's the Difference?'
We encountered a peculiar bug where swiftUI slider component refused to work specifically on iOS 17. Initially, everything pointed to a straightforward iOS version issue.
So to tackle such a problem I first looked at the slider api and how it was utilized and it seemed okay nothing wrong with it.
The second thing I noticed is the view layout, I suspected something in the view layout might be preventing the slider from functioning properly, so I took the slider api and removed everything in the subView but still it didn't work.
I started to feel like it is something related to iOS 17, so to make sure I took the same api and added it to a new project, built the project slider and it worked fine at this point I started to scratch my head ๐ค
By this experiment we reached an important conclusion that there is something in the layout of the parent view that utilize the subView that contains the slider. I found out that we were using scrollView and inside the scrollView I used a GemotryReader in side of it. I tried the same thing in a sprite project and found that it didn't work too.
โSo the problem is that in iOS 17 slider doesn't work when you add it to a GeometryReader in side of a scrollView without specifying the position of the slider. And from it I learned "What is different ?" technique.
When you encounter a bug that only appears in your production code but works fine in isolation, ask yourself: "What's the difference between these implementations?" In my experience, this simple question leads to solution about 80% of the time.
This approach has become one of my most reliable debugging techniques throughout my career. It forces you to systematically identify variables and context differences, often revealing subtle implementation issues that aren't immediately apparent.
Remember: The most challenging bugs often hide in the gaps between working and non-working scenarios. Your job as a developer is to find those gaps.
SwiftUI Resources
โ
I hope you enjoy the todays issue number 3*, if you have any feedback contact me at engomarelsayed@icloud.com
See you next week where our focus will be personal growth.
Made with โค๏ธ by Omar Elsayed