SlideShare a Scribd company logo
Advanced iOS Debugging
Massimo Oliviero
Massimo Oliviero
Freelance Software Developer
web http://www.massimooliviero.net
email massimo.oliviero@gmail.com
slide http://www.slideshare.net/MassimoOliviero
twitter @maxoly
Agenda
‣ Code, some tips for standard functions
‣ Xcode, the best tools for debugging
‣ LLDB, your great friend
‣ Tools, network debugging how to and more
‣ Remote, over the air debugging
‣ Resources, links and videos
Source code
Kimera
A simple iOS application for educational purpose
https://github.com/maxoly/Kimera
Code
It all began...
NSLog(@"Error :( %@", error);
NSLog(@"User: %@", user);
NSLog(@"Array: %@", array);
NSLog(@"URL: %@", url);
NSLog(@"Count: %i", count);NSLog(@"User %@",
user);
NSLog(@"Array %@",
array);
NSLog(@"Error :( %@", error);
NSLog(@"Error :( %@", error
NSLog(@"URL: %@", url);
NSLog(@"Array: %@", array);
NSLog(@"User:
NSLog(@"User: %@", user);NSLog(@"User: %@", user);
NSLog(@"User: %@", user);
NSLog(@"User: %@", user);
NSLog(@"User: %@", user);
NSLog(@"User: %@", user);
NSLog
‣ It prints debugs output only to the console
‣ It’s a simple native Foundation function
‣ It’s not too bad, but It’s an ancient technique
‣ It slows things down considerably (if not handled)
NSLog optimization
‣ Use convenient macro
‣ Use string conversion functions
‣ Try alternative frameworks
#if defined DEBUG
#define MYNSLog(s, ...) NSLog((@"%s [Line %d] " s), __PRETTY_FUNCTION__,
__LINE__, ##__VA_ARGS__)
#else
#define MYNSLog(s, ...)
#endif
-[TestViewController viewDidLoad] [Line 33] message
- (void)viewDidLoad
{
[super viewDidLoad];
MYNSLog(@"message");
}
MyGreatApp-prefix.pch
TestViewController.m
Console
NSLog macro
NSLog macro
‣ Enables DEBUG mode output only
‣ Outputs function name and line number
‣ Place macro into .pch file or in a header file
‣ You can use other macros like __ FILE__ (for example)
CGPoint point = CGPointMake(10.5f, 12.3f);
NSLog(@"point: %@", NSStringFromCGPoint(point));
AdvanceDebuggingExample[3050:c07] point: {10.5, 12.3}
AdvanceDebuggingExample.m
Console
String conversion functions
String conversion functions
‣ NSStringFromCGAffineTransform
‣ NSStringFromCGPoint
‣ NSStringFromCGRect
‣ NSStringFromCGSize
‣ NSStringFromUIEdgeInsets
‣ NSStringFromUIOffset
Try alternative framworks
‣ CocoaLumberjack
https://github.com/robbiehanson/CocoaLumberjack
‣ NSLogger
https://github.com/fpillet/NSLogger
‣ DMLogger
https://github.com/malcommac/DMLogger
Demo
Xcode
Xcode
‣ Configure your Behaviors
‣ Print more information with Arguments
‣ Push the limit with Build Settings
‣ Go beyond logging with Breakpoints
Behaviors
Xcode default
Debugger bar
Xcode default Behaviors
VariablesView Console
Debugger
Navigator
Xcode Behaviors
‣ Match Xcode to your Workflow
‣ Use Behaviors to control Xcode
‣ Behaviors lets you specify what should happen when a
variety of events occur (like Run)
Behaviors
When
pauses
Show Debug Navigator
Show debugger views
Change default Behavior
For example, when Running pauses:
‣ show the Breakpoint Navigator instead of Debug
Navigator
‣ show only Variable Views
‣ open another tab only with Console view
Demo
Arguments
Arguments
Product > Scheme > Edit Scheme > Arguments
Core Data Logging
-com.apple.CoreData.SQLDebug 1
Core Data and iCloud logging
-com.apple.coredata.ubiquity.logLevel 3
Build Settings
Enable Static Analyzer
Treat Warning as Error
Warnings
Warnings - Objective-C
Breakpoints
Creating and editing breakpoint
Breakpoint Navigator
Exception Breakpoint
Symbolic Breakpoint
Breakpoint Action
Breakpoint Action
Condition to evaluateThe num of time to ignore
breakpoint before stoping
Log Message Action
Debugger Command Action
Play sound
Continue program execution
Debugger Command Action
po variable
expr (void)NSLog(@”variable: %@”, variable)
breakpoint set -f ADEMasterViewController.m -l 83
Sharing Breakpoint
Share breakpoints with the team, so that all can benefit from it
This action will create a new directory to be committed in the repository
AdvanceDebuggingExample.xcodeproj/xcshareddata/
Demo
LLDB
Why LLDB
‣ Consistent Command Syntax
‣ Scriptability with Python
‣ Performance
‣ ...
LLDB Commands
print object po [object]
print variable print [variable]
assign value expr [variable] = [value]
(lldb) <command>
LLDB Commands
set breakpoint breakpoint set -f [file] -l [line]
load script command script import ~/test.py
evaluate expression expr <expression>
<noun> <verb> [-options [option-value]] [argument [argument...]]
Custom Object, the problem
No summary for custom object
@interface KMRMArgument : NSObject
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSDate *detail;
@end
KMRMArgument *argument = [[KMRMArgument alloc] init];
argument.title = @"Debugging";
argument.when = @"Some advance techniques";
Init object
Custom object
Custom Summary, the solution
‣ Create a Python script that will instruct LLDB on how to
display a summary of your custom object
‣ Load your Python script via command line or ~/.lldbinit
file
Custom Summary
‣ Create“KMRMArgument_summary.py”in Xcode project
‣ Then load script:
(lldb) command script import /path/to/KMRMArgument_summary.py
import lldb
def arg_summary(valobj, internal_dict):
! nameAsString = valobj.GetChildMemberWithName('_name').GetSummary()
! detailAsString = valobj.GetChildMemberWithName('_detail').GetSummary()
! return 'Title: ' + nameAsString + ' - detail: ' + detailAsString
def __lldb_init_module(debugger, dict):
debugger.HandleCommand('type summary add KRMRArgument -F KRMRArgument_summary.arg_summary')
Console tips
(lldb) po [self.view recursiveDescription]
$7 = 0x082a2c60 <UITableView: 0x8971000; frame = (0 0; 320 504); clipsToBounds = YES; autoresize = W+H;
gestureRecognizers = <NSArray: 0x8184be0>; layer = <CALayer: 0x8184570>; contentOffset: {0, 0}>
| <UITableViewCell: 0x8282900; frame = (0 176; 320 44); text = '2013-03-12 21:22:34 +0000'; autoresize = W;
layer = <CALayer: 0x8282a30>>
| | <UITableViewCellContentView: 0x8282a60; frame = (0 0; 300 43); gestureRecognizers = <NSArray:
0x8282c30>; layer = <CALayer: 0x8282ac0>>
| | | <UILabel: 0x8282e50; frame = (10 0; 280 43); text = '2013-03-12 21:22:34 +0000'; clipsToBounds
= YES; userInteractionEnabled = NO; layer = <CALayer: 0x8282ee0>>
| | <UIButton: 0x8282c80; frame = (290 0; 30 43); opaque = NO; userInteractionEnabled = NO; layer = ...
(lldb) po [[UIWindow keyWindow] recursiveDescription]
$5 = 0x08273bc0 <UIWindow: 0x8181010; frame = (0 0; 320 568); layer = <UIWindowLayer: 0x81810e0>>
| <UILayoutContainerView: 0xd06eed0; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer:
0xd071460>>
| | <UINavigationTransitionView: 0xd09e850; frame = (0 0; 320 568); clipsToBounds = YES; autoresize = W
+H; layer = <CALayer: 0xd09e920>>
| | | <UIViewControllerWrapperView: 0x846e160; frame = (0 64; 320 504); autoresize = W+H; layer =
<CALayer: 0x846e210>>
...
Demo
Tools
Tools
‣ Network Link Conditioner
‣ Charles
‣ PonyDebugger
‣ Deploymate
‣ Spark Inspector
Network Link
Conditioner
Network Link Conditioner
‣ It’s a utility that enables you to simulate network
conditions
‣ To install just select Xcode > Open Developer Tool >
More Developer Tools. You’ll be taken to Apple’s
developer downloads site
‣ Download“Hardware IO Tools for Xcode”
Network Link Conditioner
Charles
Charles Proxy
‣ It’s a web debugging proxy
‣ You can inspect, modify and record requests &
responses
‣ SSL Proxing
http://www.charlesproxy.com/documentation/faqs/ssl-connections-
from-within-iphone-applications/
‣ http://www.charlesproxy.com
‣ Price start from US$50
Charles Proxy
PonyDebugger
PonyDebugger
‣ Network Traffic Debugger
‣ Core Data Browser
‣ It is a client library and gateway server combination
that uses Chrome Developer Tools on your browser to
debug your application's network traffic and managed
object contexts.
‣ https://github.com/square/PonyDebugger
PonyDebugger
Deploymate
Deploymate
‣ If using an API introduced later than your target OS but
your app is targeting an older OS version, Xcode
doesn't warn you about it
‣ It helps identify unavailable, deprecated and obsolete
API
‣ http://www.deploymateapp.com/
‣ Price US$19.99
Deploymate
Spark Inspector
Spark Inspector
‣ Runtime Debugger for iOS
‣ Monitor & Experiment in Real-time
‣ See Notifications in Real-time
‣ http://sparkinspector.com/
‣ Price € 31,79
Spark Inspector
Demo
Remote
Remote debugging
‣ Apple Crash Reports
‣ PLCrashReporter
‣ TestFlight
Apple Crash Reports
Apple Crash Reports
‣ For app published on App Store, you can acquire crash
log from iTunes Connect and import it into Organizer
for symbolication
‣ To symbolicate a crash log, Xcode needs to have access
to the matching application binary that was uploaded
to the App Store, and the .dSYM file that was
generated when that binary was built. This must be an
exact match
‣ https://itunesconnect.apple.com
Apple Crash Reports
Apple Crash Reports
Xcode Symbolication
PLCrashReporter
PLCrashReporter
‣ In-process CrashReporter framework for the iPhone
and Mac OS X
‣ Handles both uncaught Objective-C exceptions and
fatal signals
‣ Backtraces for all active threads are provided
‣ https://code.google.com/p/plcrashreporter/
PLCrashReporter
- (void) handleCrashReport {
PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
NSData *crashData;
NSError *error;
// Try loading the crash report
crashData = [crashReporter loadPendingCrashReportDataAndReturnError: &error];
if (crashData == nil) {
NSLog(@"Could not load crash report: %@", error);
goto finish;
}
PLCrashReport *report = [[[PLCrashReport alloc] initWithData: crashData error: &error] autorelease];
if (report == nil) {
NSLog(@"Could not parse crash report");
goto finish;
}
....
return;
}
// from UIApplicationDelegate protocol
- (void) applicationDidFinishLaunching: (UIApplication *) application {
PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter];
NSError *error;
// Check if we previously crashed
if ([crashReporter hasPendingCrashReport])
[self handleCrashReport];
// Enable the Crash Reporter
if (![crashReporter enableCrashReporterAndReturnError: &error])
NSLog(@"Warning: Could not enable crash reporter: %@", error);
}
TestFlight
TestFlight
‣ Invite your testers, drop in the SDK and start uploading
your builds.
‣ Upload your builds and TestFlight takes care of the
rest. Painless over-the-air distribution to your testers
and distribution lists.
‣ Complete tracking of your build, from distribution to
sessions, checkpoints and crashes.
‣ https://testflightapp.com
TestFlight Apps Management
TestFlight Crashes
Resources
Resources
‣ Links
‣ Videos
Links
Links
‣ Overview of iOS Crash Reporting Tools
http://www.raywenderlich.com/33669/overview-of-ios-crash-
reporting-tools-part-1
http://www.raywenderlich.com/33669/overview-of-ios-crash-
reporting-tools-part-2
‣ How to use Instruments in Xcode
http://www.raywenderlich.com/23037/how-to-use-instruments-in-
xcode
‣ Demystifying iOS Application Crash Log
http://www.raywenderlich.com/23704/demystifying-ios-application-
crash-logs
Links
‣ Intermediate Debugging with Xcode 4.5
http://www.raywenderlich.com/28289/debugging-ios-apps-in-
xcode-4-5
‣ Xcode LLDB Tutorial
http://www.cimgf.com/2012/12/13/xcode-lldb-tutorial/
‣ iOS Simulator Tips & Tricks
http://mobile.tutsplus.com/tutorials/iphone/ios-simulator/
Links
‣ Compiler Warnings for Objective-C Developers
http://oleb.net/blog/2013/04/compiler-warnings-for-objective-c-
developers/
‣ Defensive Programming in Cocoa
http://www.mikeash.com/pyblog/friday-qa-2010-08-27-defensive-
programming-in-cocoa.html
‣ Testing and Debugging in iOS Simulator
https://developer.apple.com/library/ios/#documentation/IDEs/
Conceptual/iOS_Simulator_Guide/TestingontheiOSSimulator/
TestingontheiOSSimulator.html
Links
‣ iOS Debugging (slide by Dave Kozol)
http://arbormoon.com/sites/default/files/
ASIDebuggingCocoaConfChicago.pdf
‣ Strong, Better, Faster with Instruments and Debugging
(slide by Kyle Richter)
http://dragonforged.com/CocoaConf.pdf
‣ LLDB Script Examples
http://llvm.org/svn/llvm-project/lldb/trunk/examples/
Videos
Videos
‣ WWDC 2012 - 415 - Debugging with LLDB
‣ WWDC 2011 - 321 - Migrating from GDB to LLDB
‣ WWDC 2010 - 316 - Debugging with Xcode 4 and LLDB
‣ NSScreenCast - 002 - Memory Problems
Final Thoughts
Final Thoughts
‣ Don’t use NSLog anymore ;)
‣ Create your Xcode Behaviors
‣ Breakpoints are your friends
‣ LLDB is a promising youngster
‣ Tools can save your life
‣ The QA phase is essential
Thank you
Massimo Oliviero
massimo.oliviero@gmail.com
http://www.massimooliviero.net
follow me on twitter @maxoly
http://www.slideshare.net/MassimoOliviero
https://speakerdeck.com/massimooliviero
Ad

More Related Content

What's hot (19)

Architecting iOS Project
Architecting iOS ProjectArchitecting iOS Project
Architecting iOS Project
Massimo Oliviero
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and Debugging
Rich Helton
 
Learning C# iPad Programming
Learning C# iPad ProgrammingLearning C# iPad Programming
Learning C# iPad Programming
Rich Helton
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
apoorvams
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
Aravindharamanan S
 
Java fx smart code econ
Java fx smart code econJava fx smart code econ
Java fx smart code econ
Tom Schindl
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
Fabien Potencier
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
Lars Vogel
 
Apache Ant
Apache AntApache Ant
Apache Ant
Rajesh Kumar
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
Kanika2885
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFX
Tom Mix Petreca
 
Eclipse 40 and Eclipse e4
Eclipse 40 and Eclipse e4 Eclipse 40 and Eclipse e4
Eclipse 40 and Eclipse e4
Lars Vogel
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
Christian Heilmann
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
scidept
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
Vijay A Raj
 
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
Hazem Saleh
 
Android Auto instrumentation
Android Auto instrumentationAndroid Auto instrumentation
Android Auto instrumentation
Przemek Jakubczyk
 
Breaking iOS Apps using Cycript
Breaking iOS Apps using CycriptBreaking iOS Apps using Cycript
Breaking iOS Apps using Cycript
n|u - The Open Security Community
 
Building maintainable javascript applications
Building maintainable javascript applicationsBuilding maintainable javascript applications
Building maintainable javascript applications
equisodie
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and Debugging
Rich Helton
 
Learning C# iPad Programming
Learning C# iPad ProgrammingLearning C# iPad Programming
Learning C# iPad Programming
Rich Helton
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
apoorvams
 
Java fx smart code econ
Java fx smart code econJava fx smart code econ
Java fx smart code econ
Tom Schindl
 
Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3Design patterns revisited with PHP 5.3
Design patterns revisited with PHP 5.3
Fabien Potencier
 
Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010Eclipse e4 on Java Forum Stuttgart 2010
Eclipse e4 on Java Forum Stuttgart 2010
Lars Vogel
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
Kanika2885
 
Presentation - Course about JavaFX
Presentation - Course about JavaFXPresentation - Course about JavaFX
Presentation - Course about JavaFX
Tom Mix Petreca
 
Eclipse 40 and Eclipse e4
Eclipse 40 and Eclipse e4 Eclipse 40 and Eclipse e4
Eclipse 40 and Eclipse e4
Lars Vogel
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
scidept
 
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
Hazem Saleh
 
Android Auto instrumentation
Android Auto instrumentationAndroid Auto instrumentation
Android Auto instrumentation
Przemek Jakubczyk
 
Building maintainable javascript applications
Building maintainable javascript applicationsBuilding maintainable javascript applications
Building maintainable javascript applications
equisodie
 

Similar to Advanced iOS Debbuging (Reloaded) (20)

PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
Andrey Karpov
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
Bala Subra
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
Bala Subra
 
[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova
[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova
[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova
Hazem Saleh
 
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NCAndroid Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Jim Tochterman
 
2013-03-07 indie developer toolkit
2013-03-07 indie developer toolkit2013-03-07 indie developer toolkit
2013-03-07 indie developer toolkit
CocoaHeads Tricity
 
Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2
Matthew McCullough
 
Тестирование мобильных приложений используя облачные сервисы. TestDroid, Test...
Тестирование мобильных приложений используя облачные сервисы. TestDroid, Test...Тестирование мобильных приложений используя облачные сервисы. TestDroid, Test...
Тестирование мобильных приложений используя облачные сервисы. TestDroid, Test...
COMAQA.BY
 
Analyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile Web
Ariya Hidayat
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
Bramus Van Damme
 
iOS Indie Developer Toolkit - CocoaHeads 3city
iOS Indie Developer Toolkit - CocoaHeads 3cityiOS Indie Developer Toolkit - CocoaHeads 3city
iOS Indie Developer Toolkit - CocoaHeads 3city
Michał Zygar
 
Introduction to aop
Introduction to aopIntroduction to aop
Introduction to aop
Dror Helper
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp Philly
Brian Lyttle
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
Simon Willison
 
Necto 16 training 20 component mode &amp; java script
Necto 16 training 20   component mode &amp; java scriptNecto 16 training 20   component mode &amp; java script
Necto 16 training 20 component mode &amp; java script
Panorama Software
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
Jim Jeffers
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
Association Paris-Web
 
Android tools
Android toolsAndroid tools
Android tools
Alexey Ustenko
 
Android Logging System
Android Logging SystemAndroid Logging System
Android Logging System
William Lee
 
Platform agnostic information systems development
Platform agnostic information systems developmentPlatform agnostic information systems development
Platform agnostic information systems development
Mark Jayson Fuentes
 
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
PVS-Studio and Continuous Integration: TeamCity. Analysis of the Open RollerC...
Andrey Karpov
 
.Net Debugging Techniques
.Net Debugging Techniques.Net Debugging Techniques
.Net Debugging Techniques
Bala Subra
 
.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques.NET Debugging Tips and Techniques
.NET Debugging Tips and Techniques
Bala Subra
 
[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova
[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova
[JavaLand 2015] Developing JavaScript Mobile Apps Using Apache Cordova
Hazem Saleh
 
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NCAndroid Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Android Development w/ ArcGIS Server - Esri Dev Meetup - Charlotte, NC
Jim Tochterman
 
2013-03-07 indie developer toolkit
2013-03-07 indie developer toolkit2013-03-07 indie developer toolkit
2013-03-07 indie developer toolkit
CocoaHeads Tricity
 
Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2Google App Engine for Java v0.0.2
Google App Engine for Java v0.0.2
Matthew McCullough
 
Тестирование мобильных приложений используя облачные сервисы. TestDroid, Test...
Тестирование мобильных приложений используя облачные сервисы. TestDroid, Test...Тестирование мобильных приложений используя облачные сервисы. TestDroid, Test...
Тестирование мобильных приложений используя облачные сервисы. TestDroid, Test...
COMAQA.BY
 
Analyzing the Performance of Mobile Web
Analyzing the Performance of Mobile WebAnalyzing the Performance of Mobile Web
Analyzing the Performance of Mobile Web
Ariya Hidayat
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
Bramus Van Damme
 
iOS Indie Developer Toolkit - CocoaHeads 3city
iOS Indie Developer Toolkit - CocoaHeads 3cityiOS Indie Developer Toolkit - CocoaHeads 3city
iOS Indie Developer Toolkit - CocoaHeads 3city
Michał Zygar
 
Introduction to aop
Introduction to aopIntroduction to aop
Introduction to aop
Dror Helper
 
Production Debugging at Code Camp Philly
Production Debugging at Code Camp PhillyProduction Debugging at Code Camp Philly
Production Debugging at Code Camp Philly
Brian Lyttle
 
JavaScript Libraries: The Big Picture
JavaScript Libraries: The Big PictureJavaScript Libraries: The Big Picture
JavaScript Libraries: The Big Picture
Simon Willison
 
Necto 16 training 20 component mode &amp; java script
Necto 16 training 20   component mode &amp; java scriptNecto 16 training 20   component mode &amp; java script
Necto 16 training 20 component mode &amp; java script
Panorama Software
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
Jim Jeffers
 
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
IE 8 et les standards du Web - Chris Wilson - Paris Web 2008
Association Paris-Web
 
Android Logging System
Android Logging SystemAndroid Logging System
Android Logging System
William Lee
 
Platform agnostic information systems development
Platform agnostic information systems developmentPlatform agnostic information systems development
Platform agnostic information systems development
Mark Jayson Fuentes
 
Ad

More from Massimo Oliviero (7)

Modernize your Objective-C
Modernize your Objective-CModernize your Objective-C
Modernize your Objective-C
Massimo Oliviero
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & Architecture
Massimo Oliviero
 
Presentazione Community Pragma Mark
Presentazione Community Pragma MarkPresentazione Community Pragma Mark
Presentazione Community Pragma Mark
Massimo Oliviero
 
iOS Programming
iOS ProgrammingiOS Programming
iOS Programming
Massimo Oliviero
 
iOS - Getting Started
iOS - Getting StartediOS - Getting Started
iOS - Getting Started
Massimo Oliviero
 
iOS Ecosystem
iOS EcosystemiOS Ecosystem
iOS Ecosystem
Massimo Oliviero
 
iOS Api Client: soluzioni a confronto
iOS Api Client: soluzioni a confrontoiOS Api Client: soluzioni a confronto
iOS Api Client: soluzioni a confronto
Massimo Oliviero
 
Modernize your Objective-C
Modernize your Objective-CModernize your Objective-C
Modernize your Objective-C
Massimo Oliviero
 
Building iOS App Project & Architecture
Building iOS App Project & ArchitectureBuilding iOS App Project & Architecture
Building iOS App Project & Architecture
Massimo Oliviero
 
Presentazione Community Pragma Mark
Presentazione Community Pragma MarkPresentazione Community Pragma Mark
Presentazione Community Pragma Mark
Massimo Oliviero
 
iOS Api Client: soluzioni a confronto
iOS Api Client: soluzioni a confrontoiOS Api Client: soluzioni a confronto
iOS Api Client: soluzioni a confronto
Massimo Oliviero
 
Ad

Recently uploaded (20)

The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 

Advanced iOS Debbuging (Reloaded)

  • 2. Massimo Oliviero Freelance Software Developer web http://www.massimooliviero.net email [email protected] slide http://www.slideshare.net/MassimoOliviero twitter @maxoly
  • 3. Agenda ‣ Code, some tips for standard functions ‣ Xcode, the best tools for debugging ‣ LLDB, your great friend ‣ Tools, network debugging how to and more ‣ Remote, over the air debugging ‣ Resources, links and videos
  • 4. Source code Kimera A simple iOS application for educational purpose https://github.com/maxoly/Kimera
  • 6. It all began... NSLog(@"Error :( %@", error); NSLog(@"User: %@", user); NSLog(@"Array: %@", array); NSLog(@"URL: %@", url); NSLog(@"Count: %i", count);NSLog(@"User %@", user); NSLog(@"Array %@", array); NSLog(@"Error :( %@", error); NSLog(@"Error :( %@", error NSLog(@"URL: %@", url); NSLog(@"Array: %@", array); NSLog(@"User: NSLog(@"User: %@", user);NSLog(@"User: %@", user); NSLog(@"User: %@", user); NSLog(@"User: %@", user); NSLog(@"User: %@", user); NSLog(@"User: %@", user);
  • 7. NSLog ‣ It prints debugs output only to the console ‣ It’s a simple native Foundation function ‣ It’s not too bad, but It’s an ancient technique ‣ It slows things down considerably (if not handled)
  • 8. NSLog optimization ‣ Use convenient macro ‣ Use string conversion functions ‣ Try alternative frameworks
  • 9. #if defined DEBUG #define MYNSLog(s, ...) NSLog((@"%s [Line %d] " s), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) #else #define MYNSLog(s, ...) #endif -[TestViewController viewDidLoad] [Line 33] message - (void)viewDidLoad { [super viewDidLoad]; MYNSLog(@"message"); } MyGreatApp-prefix.pch TestViewController.m Console NSLog macro
  • 10. NSLog macro ‣ Enables DEBUG mode output only ‣ Outputs function name and line number ‣ Place macro into .pch file or in a header file ‣ You can use other macros like __ FILE__ (for example)
  • 11. CGPoint point = CGPointMake(10.5f, 12.3f); NSLog(@"point: %@", NSStringFromCGPoint(point)); AdvanceDebuggingExample[3050:c07] point: {10.5, 12.3} AdvanceDebuggingExample.m Console String conversion functions
  • 12. String conversion functions ‣ NSStringFromCGAffineTransform ‣ NSStringFromCGPoint ‣ NSStringFromCGRect ‣ NSStringFromCGSize ‣ NSStringFromUIEdgeInsets ‣ NSStringFromUIOffset
  • 13. Try alternative framworks ‣ CocoaLumberjack https://github.com/robbiehanson/CocoaLumberjack ‣ NSLogger https://github.com/fpillet/NSLogger ‣ DMLogger https://github.com/malcommac/DMLogger
  • 14. Demo
  • 15. Xcode
  • 16. Xcode ‣ Configure your Behaviors ‣ Print more information with Arguments ‣ Push the limit with Build Settings ‣ Go beyond logging with Breakpoints
  • 19. Xcode default Behaviors VariablesView Console Debugger Navigator
  • 20. Xcode Behaviors ‣ Match Xcode to your Workflow ‣ Use Behaviors to control Xcode ‣ Behaviors lets you specify what should happen when a variety of events occur (like Run)
  • 22. Change default Behavior For example, when Running pauses: ‣ show the Breakpoint Navigator instead of Debug Navigator ‣ show only Variable Views ‣ open another tab only with Console view
  • 23. Demo
  • 25. Arguments Product > Scheme > Edit Scheme > Arguments
  • 27. Core Data and iCloud logging -com.apple.coredata.ubiquity.logLevel 3
  • 34. Creating and editing breakpoint
  • 39. Breakpoint Action Condition to evaluateThe num of time to ignore breakpoint before stoping Log Message Action Debugger Command Action Play sound Continue program execution
  • 40. Debugger Command Action po variable expr (void)NSLog(@”variable: %@”, variable) breakpoint set -f ADEMasterViewController.m -l 83
  • 41. Sharing Breakpoint Share breakpoints with the team, so that all can benefit from it This action will create a new directory to be committed in the repository AdvanceDebuggingExample.xcodeproj/xcshareddata/
  • 42. Demo
  • 43. LLDB
  • 44. Why LLDB ‣ Consistent Command Syntax ‣ Scriptability with Python ‣ Performance ‣ ...
  • 45. LLDB Commands print object po [object] print variable print [variable] assign value expr [variable] = [value] (lldb) <command>
  • 46. LLDB Commands set breakpoint breakpoint set -f [file] -l [line] load script command script import ~/test.py evaluate expression expr <expression> <noun> <verb> [-options [option-value]] [argument [argument...]]
  • 47. Custom Object, the problem No summary for custom object @interface KMRMArgument : NSObject @property (nonatomic, strong) NSString *name; @property (nonatomic, strong) NSDate *detail; @end KMRMArgument *argument = [[KMRMArgument alloc] init]; argument.title = @"Debugging"; argument.when = @"Some advance techniques"; Init object Custom object
  • 48. Custom Summary, the solution ‣ Create a Python script that will instruct LLDB on how to display a summary of your custom object ‣ Load your Python script via command line or ~/.lldbinit file
  • 49. Custom Summary ‣ Create“KMRMArgument_summary.py”in Xcode project ‣ Then load script: (lldb) command script import /path/to/KMRMArgument_summary.py import lldb def arg_summary(valobj, internal_dict): ! nameAsString = valobj.GetChildMemberWithName('_name').GetSummary() ! detailAsString = valobj.GetChildMemberWithName('_detail').GetSummary() ! return 'Title: ' + nameAsString + ' - detail: ' + detailAsString def __lldb_init_module(debugger, dict): debugger.HandleCommand('type summary add KRMRArgument -F KRMRArgument_summary.arg_summary')
  • 50. Console tips (lldb) po [self.view recursiveDescription] $7 = 0x082a2c60 <UITableView: 0x8971000; frame = (0 0; 320 504); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x8184be0>; layer = <CALayer: 0x8184570>; contentOffset: {0, 0}> | <UITableViewCell: 0x8282900; frame = (0 176; 320 44); text = '2013-03-12 21:22:34 +0000'; autoresize = W; layer = <CALayer: 0x8282a30>> | | <UITableViewCellContentView: 0x8282a60; frame = (0 0; 300 43); gestureRecognizers = <NSArray: 0x8282c30>; layer = <CALayer: 0x8282ac0>> | | | <UILabel: 0x8282e50; frame = (10 0; 280 43); text = '2013-03-12 21:22:34 +0000'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x8282ee0>> | | <UIButton: 0x8282c80; frame = (290 0; 30 43); opaque = NO; userInteractionEnabled = NO; layer = ... (lldb) po [[UIWindow keyWindow] recursiveDescription] $5 = 0x08273bc0 <UIWindow: 0x8181010; frame = (0 0; 320 568); layer = <UIWindowLayer: 0x81810e0>> | <UILayoutContainerView: 0xd06eed0; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0xd071460>> | | <UINavigationTransitionView: 0xd09e850; frame = (0 0; 320 568); clipsToBounds = YES; autoresize = W +H; layer = <CALayer: 0xd09e920>> | | | <UIViewControllerWrapperView: 0x846e160; frame = (0 64; 320 504); autoresize = W+H; layer = <CALayer: 0x846e210>> ...
  • 51. Demo
  • 52. Tools
  • 53. Tools ‣ Network Link Conditioner ‣ Charles ‣ PonyDebugger ‣ Deploymate ‣ Spark Inspector
  • 55. Network Link Conditioner ‣ It’s a utility that enables you to simulate network conditions ‣ To install just select Xcode > Open Developer Tool > More Developer Tools. You’ll be taken to Apple’s developer downloads site ‣ Download“Hardware IO Tools for Xcode”
  • 58. Charles Proxy ‣ It’s a web debugging proxy ‣ You can inspect, modify and record requests & responses ‣ SSL Proxing http://www.charlesproxy.com/documentation/faqs/ssl-connections- from-within-iphone-applications/ ‣ http://www.charlesproxy.com ‣ Price start from US$50
  • 61. PonyDebugger ‣ Network Traffic Debugger ‣ Core Data Browser ‣ It is a client library and gateway server combination that uses Chrome Developer Tools on your browser to debug your application's network traffic and managed object contexts. ‣ https://github.com/square/PonyDebugger
  • 64. Deploymate ‣ If using an API introduced later than your target OS but your app is targeting an older OS version, Xcode doesn't warn you about it ‣ It helps identify unavailable, deprecated and obsolete API ‣ http://www.deploymateapp.com/ ‣ Price US$19.99
  • 67. Spark Inspector ‣ Runtime Debugger for iOS ‣ Monitor & Experiment in Real-time ‣ See Notifications in Real-time ‣ http://sparkinspector.com/ ‣ Price € 31,79
  • 69. Demo
  • 71. Remote debugging ‣ Apple Crash Reports ‣ PLCrashReporter ‣ TestFlight
  • 73. Apple Crash Reports ‣ For app published on App Store, you can acquire crash log from iTunes Connect and import it into Organizer for symbolication ‣ To symbolicate a crash log, Xcode needs to have access to the matching application binary that was uploaded to the App Store, and the .dSYM file that was generated when that binary was built. This must be an exact match ‣ https://itunesconnect.apple.com
  • 78. PLCrashReporter ‣ In-process CrashReporter framework for the iPhone and Mac OS X ‣ Handles both uncaught Objective-C exceptions and fatal signals ‣ Backtraces for all active threads are provided ‣ https://code.google.com/p/plcrashreporter/
  • 79. PLCrashReporter - (void) handleCrashReport { PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter]; NSData *crashData; NSError *error; // Try loading the crash report crashData = [crashReporter loadPendingCrashReportDataAndReturnError: &error]; if (crashData == nil) { NSLog(@"Could not load crash report: %@", error); goto finish; } PLCrashReport *report = [[[PLCrashReport alloc] initWithData: crashData error: &error] autorelease]; if (report == nil) { NSLog(@"Could not parse crash report"); goto finish; } .... return; } // from UIApplicationDelegate protocol - (void) applicationDidFinishLaunching: (UIApplication *) application { PLCrashReporter *crashReporter = [PLCrashReporter sharedReporter]; NSError *error; // Check if we previously crashed if ([crashReporter hasPendingCrashReport]) [self handleCrashReport]; // Enable the Crash Reporter if (![crashReporter enableCrashReporterAndReturnError: &error]) NSLog(@"Warning: Could not enable crash reporter: %@", error); }
  • 81. TestFlight ‣ Invite your testers, drop in the SDK and start uploading your builds. ‣ Upload your builds and TestFlight takes care of the rest. Painless over-the-air distribution to your testers and distribution lists. ‣ Complete tracking of your build, from distribution to sessions, checkpoints and crashes. ‣ https://testflightapp.com
  • 86. Links
  • 87. Links ‣ Overview of iOS Crash Reporting Tools http://www.raywenderlich.com/33669/overview-of-ios-crash- reporting-tools-part-1 http://www.raywenderlich.com/33669/overview-of-ios-crash- reporting-tools-part-2 ‣ How to use Instruments in Xcode http://www.raywenderlich.com/23037/how-to-use-instruments-in- xcode ‣ Demystifying iOS Application Crash Log http://www.raywenderlich.com/23704/demystifying-ios-application- crash-logs
  • 88. Links ‣ Intermediate Debugging with Xcode 4.5 http://www.raywenderlich.com/28289/debugging-ios-apps-in- xcode-4-5 ‣ Xcode LLDB Tutorial http://www.cimgf.com/2012/12/13/xcode-lldb-tutorial/ ‣ iOS Simulator Tips & Tricks http://mobile.tutsplus.com/tutorials/iphone/ios-simulator/
  • 89. Links ‣ Compiler Warnings for Objective-C Developers http://oleb.net/blog/2013/04/compiler-warnings-for-objective-c- developers/ ‣ Defensive Programming in Cocoa http://www.mikeash.com/pyblog/friday-qa-2010-08-27-defensive- programming-in-cocoa.html ‣ Testing and Debugging in iOS Simulator https://developer.apple.com/library/ios/#documentation/IDEs/ Conceptual/iOS_Simulator_Guide/TestingontheiOSSimulator/ TestingontheiOSSimulator.html
  • 90. Links ‣ iOS Debugging (slide by Dave Kozol) http://arbormoon.com/sites/default/files/ ASIDebuggingCocoaConfChicago.pdf ‣ Strong, Better, Faster with Instruments and Debugging (slide by Kyle Richter) http://dragonforged.com/CocoaConf.pdf ‣ LLDB Script Examples http://llvm.org/svn/llvm-project/lldb/trunk/examples/
  • 92. Videos ‣ WWDC 2012 - 415 - Debugging with LLDB ‣ WWDC 2011 - 321 - Migrating from GDB to LLDB ‣ WWDC 2010 - 316 - Debugging with Xcode 4 and LLDB ‣ NSScreenCast - 002 - Memory Problems
  • 94. Final Thoughts ‣ Don’t use NSLog anymore ;) ‣ Create your Xcode Behaviors ‣ Breakpoints are your friends ‣ LLDB is a promising youngster ‣ Tools can save your life ‣ The QA phase is essential
  • 95. Thank you Massimo Oliviero [email protected] http://www.massimooliviero.net follow me on twitter @maxoly http://www.slideshare.net/MassimoOliviero https://speakerdeck.com/massimooliviero