Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Debugging in Swift
Search
Carola Nitz
March 22, 2015
Technology
19
23k
Debugging in Swift
This talk will give you some helpful tips and tricks when you struggle with Debugging
Carola Nitz
March 22, 2015
Tweet
Share
More Decks by Carola Nitz
See All by Carola Nitz
Beware of the legacy! The one you inherit and the one you create
carola
0
210
Debugging - Things your senior hasn't told you about
carola
6
1.9k
Code Snippets for Debugging
carola
1
260
Other Decks in Technology
See All in Technology
ABEMA のコンテンツ制作を最適化!生成 AI x クラウド映像編集システム / abema-ai-editor
cyberagentdevelopers
PRO
1
180
Automated Promptingを目指すその前に / Before we can aim for Automated Prompting
rkaga
0
110
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
290k
生成AIとAWS CDKで実現! 自社ブログレビューの効率化
ymae
2
330
いまならこう作りたい AWSコンテナ[本格]入門ハンズオン 〜2024年版 ハンズオンの構想〜
horsewin
9
2.1k
独自ツール開発でスタジオ撮影をDX!「VLS(Virtual LED Studio)」 / dx-studio-vls
cyberagentdevelopers
PRO
1
180
プロポーザルのつくり方 〜個人技編〜 / How to come up with proposals
ohbarye
1
110
AWS CodePipelineでコンテナアプリをデプロイした際に、古いイメージを自動で削除する
smt7174
1
110
【若手エンジニア応援LT会】AWS Security Hubの活用に苦労した話
kazushi_ohata
0
170
Amazon_CloudWatch_ログ異常検出_導入ガイド
tsujiba
4
1.6k
Forget efficiency – Become more productive without the stress
ufried
0
150
ガチ勢によるPipeCD運用大全〜滑らかなCI/CDを添えて〜 / ai-pipecd-encyclopedia
cyberagentdevelopers
PRO
3
210
Featured
See All Featured
Optimizing for Happiness
mojombo
376
69k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
41
2.1k
We Have a Design System, Now What?
morganepeng
50
7.2k
Thoughts on Productivity
jonyablonski
67
4.3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
Making the Leap to Tech Lead
cromwellryan
132
8.9k
How to train your dragon (web standard)
notwaldorf
88
5.7k
It's Worth the Effort
3n
183
27k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
Code Reviewing Like a Champion
maltzj
519
39k
Transcript
Debugging in Swift how hard can it be @_Caro _N,
22/3/2015
Why do we struggle with debugging? @_Caro _N, 22/3/2015
Output is not helpful (lldb) po objectiveCString 0x00007fbaa1f24910 (ObjectiveC.NSObject =
{}) @_Caro _N, 22/3/2015
Error messages make no sense @_Caro _N, 22/3/2015
What?! That tool exists? @_Caro _N, 22/3/2015
How debugging should be like • Get to the content
of interest @_Caro _N, 22/3/2015
How debugging should be like • Get to the content
of interest • Get helpful error messages @_Caro _N, 22/3/2015
How debugging should be like • Get to the content
of interest • Get helpful error messages • Display additional information where needed @_Caro _N, 22/3/2015
How debugging should be like • Get to the content
of interest • Get helpful error messages • Display additional information where needed • Know about debugging tools @_Caro _N, 22/3/2015
LLDB @_Caro _N, 22/3/2015
Expression (lldb) po objectiveCString 0x00007fbaa1f24910 (ObjectiveC.NSObject = {}) @_Caro _N,
22/3/2015
Expression (lldb) expression -O -- objectiveCString 0x00007fbaa1f24910 (ObjectiveC.NSObject = {})
@_Caro _N, 22/3/2015
Magic command (lldb) expression -l objc -O -- (id) 0x00007fbaa1f24910
@_Caro _N, 22/3/2015
Magic command (lldb) expression -l objc -O -- (id) 0x00007fbaa1f24910
I'm a fancy Objective-C String @_Caro _N, 22/3/2015
Breakpoints @_Caro _N, 22/3/2015
Editing Breakpoints @_Caro _N, 22/3/2015
Editing Breakpoints @_Caro _N, 22/3/2015
Editing Breakpoints @_Caro _N, 22/3/2015
Projectwide Breakpoints • Catch Objective-C or C++ Exceptions on throw
or catch @_Caro _N, 22/3/2015
Projectwide Breakpoints • Catch Objective-C or C++ Exceptions on throw
or catch @_Caro _N, 22/3/2015
Projectwide Breakpoints • Catch Objective-C or C++ Exceptions on throw
or catch • Catch OpenGL ES errors @_Caro _N, 22/3/2015
Projectwide Breakpoints • Catch Objective-C or C++ Exceptions on throw
or catch • Catch OpenGL ES errors • Stop when executing a specific function or method @_Caro _N, 22/3/2015
Projectwide Breakpoints • Catch Objective-C or C++ Exceptions on throw
or catch • Catch OpenGL ES errors • Stop when executing a specific function or method • Stop when test Assertions fail @_Caro _N, 22/3/2015
Symbolic Breakpoints @_Caro _N, 22/3/2015
Symbolic Breakpoints @_Caro _N, 22/3/2015
Compiler errors @_Caro _N, 22/3/2015
Approach? @_Caro _N, 22/3/2015
1. Remove variables @_Caro _N, 22/3/2015
2. Split instructions @_Caro _N, 22/3/2015
Add return type @_Caro _N, 22/3/2015
Launch arguments @_Caro _N, 22/3/2015
Adding arguments in the scheme editor @_Caro _N, 22/3/2015
Concurrency -com.apple.CoreData.ConcurrencyDebug 1 @_Caro _N, 22/3/2015
SQL Statements -com.apple.CoreData.SQLDebug 3 @_Caro _N, 22/3/2015
Many more -com.apple.CoreData.MigrationDebug -com.apple.CoreData.SQLiteDebugSynchronous [0,1,2] -com.apple.CoreData.SQLiteIntegrityCheck 1 -com.apple.CoreData.ThreadingDebug [1,2,3] http://matthewmorey.com/tools-for-core-data/
@_Caro _N, 22/3/2015
Localization • -NSDoubleLocalizedStrings 1 @_Caro _N, 22/3/2015
Localization • -NSDoubleLocalizedStrings 1 • -NSShowNonLocalizedStrings 1 @_Caro _N, 22/3/2015
Localization • -NSDoubleLocalizedStrings 1 • -NSShowNonLocalizedStrings 1 • -AppleLanguages (es
de) Technical Note TN2239 iOS Debugging Magic @_Caro _N, 22/3/2015
Debugging tools @_Caro _N, 22/3/2015
Charles • Debug http/https requests • Throttle traffic • Record
download statistics @_Caro _N, 22/3/2015
Swift REPL • Test and interact with your app •
Add new code • Clean slate xcrun swift in the terminal @_Caro _N, 22/3/2015
Activity Tracing Trace crashes in asynchonous code os_activity_t activity =
os_activity_start("activity name", OS_ACTIVITY_FLAG_DEFAULT); // [...] os_activity_set_breadcrumb("event description"); // [...] os_trace("Received %d creates, %d updates, %d deletes", created, updated, deleted); // [...] os_activity_end(activity); @_Caro _N, 22/3/2015
Activity Tracing @_Caro _N, 22/3/2015
Activity Tracing http://www.objc.io/issue-19/activity-tracing.html @_Caro _N, 22/3/2015
Summary • expression -l objc -O -- (id) 0x00007fbaa1f24910 •
Edit Breakpoints, add symbolic and exception breakpoints • Tackle incomprehensive compiler errors • Launch arguments • Charles, REPL, Activity tracing @_Caro _N, 22/3/2015
Thanks @_Caro _N, 22/3/2015