debugging tips and tricks - ios conf singapore 2015
TRANSCRIPT
Bugs are what we *thought* we told the computer to do vs. what we actually told the
computer to do- Javier Soto, iOSConf Singapore 2015
Bugs
Do you do debugging on a regular basis?
Do you love debugging?
Developing for iOS is complicated
• Multiple platforms - iOS, watchOS, tvOSMultiple devices - iPhone, iPad, Apple Watch, Apple TVApps vs. extensions
History
September 9, 1947First Instance of Actual Computer Bug Found
Basics
KISS
Keep It Simple
, Stupid and Smart
Test on Device!Don’t rely on just the simulator for all your testing.If you notice a bug (or strange behaviour) on the simulator, test on a device (or several devices) too. Some issues are there just on the simulator and this can cause you many wasted hours.
Me, after hours ofSimulator Debugging
Trust in the GoogleSearch to see if others have encountered the issue. In most cases, they probably have.If you’re working with a beta version of iOS/Xcode, the Apple developer forums (http://forums.developer.apple.com/) will almost always have somebody else talking about the issue.
What Changed?Version control systems are your friend - they can help you identify what actually changed when you did that last revisionCompare versions to see if you can identify the change that is causing the bug you see.
Git Outta HereGit isn’t just for the command-line any more!• Xcode - Built-in source control functionality.• SourceTree - Free. Works with both Git and Mercurial
repositories. http://sourcetree.com • GitUp - Free. Allows you to do some complicated
operations via the GUI. http://gitup.co• GitHub Desktop - Free. Integrates with GitHub workflow.
https://desktop.github.com • Git Tower - Paid. Beautiful, clean, and functional UI.
http://git-tower.com
Crash LogsCrash logs provide a lot of valuable information to identify the root cause for a bug.Third party tools can help too:• Crashlytics/Fabric - Tiny footprint, easy to set up. Now
owned by Twitter. http://fabric.io • Hockey - Multi-platform - Android, iOS, Windows, Unity.
Now owned by Microsoft. http://hockeyapp.net
Pare it Down!Have a bug in a complicated project?Simplify it!Clone and reduce the project down to the simplest form possible where the bug is still present.
Basic Xcode Debugging
• Break points - The basic tool of debugging• Logging - Get rid of all those NSLog statements …• Watch points - How do you know when a variable changes?• Symbol breakpoints - Break on specific methods.• Exception breakpoints - Catching those elusive crashes
Debugging
Conditional BreaksBreak on specific iterations or conditions by adding a condition to the breakpoint
ThreadsThread debugging - how do you debug interactions between multiple threads?
ViewsView debugging - what do you do?
ViewsView debugging - a better way?Reveal app - http://revealapp.com
AutolayoutAutolayout constraint issues - how do you debug?
Conclusion
Questions?More questions? Or need help with debugging? Or want to discuss debugging related stuff?Contact me via e-mail at:[email protected] on Twitter:@FahimFarook