debugging tips and tricks - ios conf singapore 2015

25
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

Upload: fahim-farook

Post on 15-Apr-2017

166 views

Category:

Mobile


2 download

TRANSCRIPT

Page 1: Debugging Tips and Tricks - iOS Conf Singapore 2015

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

Page 2: Debugging Tips and Tricks - iOS Conf Singapore 2015

Bugs

Page 3: Debugging Tips and Tricks - iOS Conf Singapore 2015

Do you do debugging on a regular basis?

Page 4: Debugging Tips and Tricks - iOS Conf Singapore 2015

Do you love debugging?

Page 5: Debugging Tips and Tricks - iOS Conf Singapore 2015

Developing for iOS is complicated

• Multiple platforms - iOS, watchOS, tvOSMultiple devices - iPhone, iPad, Apple Watch, Apple TVApps vs. extensions

Fahim Farook
Developing for iOS is now very complicated - you can have bugs in iOS, WatchKit, Extension, TV, TV extensions and so on. Give examples of WatchKit issues where you didn't have the watch, or tvOS issues with iCloud, or TV extensions that can't be debugged, or 3d touch issues with no iPhone 6s
Page 6: Debugging Tips and Tricks - iOS Conf Singapore 2015

History

Page 7: Debugging Tips and Tricks - iOS Conf Singapore 2015

September 9, 1947First Instance of Actual Computer Bug Found

Page 8: Debugging Tips and Tricks - iOS Conf Singapore 2015

Basics

Fahim Farook
These are things which would be common sense. But I’m mentioning them since they could still be overlooked - and have proven helpful to me over and over again.
Page 9: Debugging Tips and Tricks - iOS Conf Singapore 2015

KISS

Keep It Simple

, Stupid and Smart

Page 10: Debugging Tips and Tricks - iOS Conf Singapore 2015

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.

Page 11: Debugging Tips and Tricks - iOS Conf Singapore 2015

Me, after hours ofSimulator Debugging

Page 12: Debugging Tips and Tricks - iOS Conf Singapore 2015

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.

Page 13: Debugging Tips and Tricks - iOS Conf Singapore 2015

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.

Page 14: Debugging Tips and Tricks - iOS Conf Singapore 2015

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

Page 15: Debugging Tips and Tricks - iOS Conf Singapore 2015

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

Page 16: Debugging Tips and Tricks - iOS Conf Singapore 2015

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.

Fahim Farook
Multiple benefits:You might see issue in your code/project that you didn’t notice before.You can send the simplified project to somebody else when asking for help.The act of simplification itself might reveal the cause of the error.
Page 17: Debugging Tips and Tricks - iOS Conf Singapore 2015

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

Page 18: Debugging Tips and Tricks - iOS Conf Singapore 2015

Debugging

Page 19: Debugging Tips and Tricks - iOS Conf Singapore 2015

Conditional BreaksBreak on specific iterations or conditions by adding a condition to the breakpoint

Page 20: Debugging Tips and Tricks - iOS Conf Singapore 2015

ThreadsThread debugging - how do you debug interactions between multiple threads?

Page 21: Debugging Tips and Tricks - iOS Conf Singapore 2015

ViewsView debugging - what do you do?

Page 22: Debugging Tips and Tricks - iOS Conf Singapore 2015

ViewsView debugging - a better way?Reveal app - http://revealapp.com

Page 23: Debugging Tips and Tricks - iOS Conf Singapore 2015

AutolayoutAutolayout constraint issues - how do you debug?

Page 24: Debugging Tips and Tricks - iOS Conf Singapore 2015

Conclusion

Page 25: Debugging Tips and Tricks - iOS Conf Singapore 2015

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