Slide 1

Slide 1 text

2016/08/20 iOS Developers Conference Japan @dealforest Toshihiro Morimoto XcodeͰշదͳσόοάϥΠϑΛ௥͍ٻΊΔ

Slide 2

Slide 2 text

Έͳ͞Μ ͜Μͳܦݧ͋Γ·ͤΜ͔ʁ ࣗݾ঺հ

Slide 3

Slide 3 text

8PSLT

Slide 4

Slide 4 text

͍͟ϦϦʔε͞ΕΔͱ... 9DPEF1MVHJO

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

ͦ͏Ͱ͢ɺצͷ͍͍Έͳ͞Μ͸͓෼͔ΓͰ͢Ͷ

Slide 7

Slide 7 text

Xcode 8 ͔Β͸ Xcode Plugin ͕ಈ͔ͳ͘ͳΓ·ͨ͠

Slide 8

Slide 8 text

RIP Xcode Plugin

Slide 9

Slide 9 text

͸͍ɺ͜Ε͔Βຊ୊Ͱ͢

Slide 10

Slide 10 text

XcodeͰշదͳσόοάϥΠϑΛ௥͍ٻΊΔ

Slide 11

Slide 11 text

iOS ΤϯδχΞʹͱͬͯ Xcode ͱ͸

Slide 12

Slide 12 text

෢࢜ʹͱͬͯͷ౛

Slide 13

Slide 13 text

ྉཧਓʹͱͬͯͷแஸ

Slide 14

Slide 14 text

Xcode ͳͯ͘͠ iOS ։ൃ͸Ͱ͖·ͤΜ

Slide 15

Slide 15 text

Xcode ͷػೳΛ׆༻͢Ε͹ σόοά͕վળ͞ΕΔ৔߹͕ଟʑ͋Γ·͢

Slide 16

Slide 16 text

ϓϩάϥϛϯάͷେ൒͸σόοάͩͱ ๻͸ࢥ͍ͬͯ·͢

Slide 17

Slide 17 text

ݪҼʹͨͲΓͭͨ͘Ίʹ ৘ใ͕ଟ͍ʹӽͨ͜͠ͱ͸͋Γ·ͤΜ

Slide 18

Slide 18 text

ͱ͍͏͜ͱͰ ීஈ͍ͯ͠Δσόοάͷ tips Λ ঺հ͍͖͍ͯͨ͠ͱࢥ͍·͢

Slide 19

Slide 19 text

• Ϋϥογϡͨ͠Β AppDelegate ͩͬͨ໰୊ • Ͳͷ ViewController ͔Θ͔Βͳ͍໰୊ • ىಈ࣌ʹಛఆͷ ViewController ʹ͍ͨ͠໰୊ • ࣮ػͷϩά΍ϑΝΠϧΛऔಘ͍ͨ͠໰୊ ຊ೔ͷ͓͠ͳ͕͖

Slide 20

Slide 20 text

Ϋϥογϡͨ͠Β AppDelegate ͩͬͨ໰୊

Slide 21

Slide 21 text

Ϋϥογϡͨ͠Β AppDelegate ͩͬͨ໰୊

Slide 22

Slide 22 text

΋͘͠͸Ξηϯϒϥͩͬͨ໰୊

Slide 23

Slide 23 text

• Exception Breakpoint Λ௥Ճ • Diagonostics Λઃఆ ղܾํ๏

Slide 24

Slide 24 text

Exception Breakpoint Λ௥Ճ

Slide 25

Slide 25 text

Exception Breakpoint Λઃఆ͓ͯ͘͠ͱɹɹ exception ͕ൃੜͨ͠λΠϛϯάͰ Break ͯ͘͠ΕΔ Exception Breakpoint Λ௥Ճ

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

্ͨͩ͠ख͘࢖͑ͳ͍έʔε΋͋ͬͯ Exception લఏͷίʔυ͕ॻ͔Ε͍ͯΔͱ ࠓճͷҙਤͱ͸ҧ͏λΠϛϯάͰ Break ͯ͠͠·͏ Exception Breakpoint Λ௥Ճ

Slide 31

Slide 31 text

্ͨͩ͠ख͘࢖͑ͳ͍έʔε΋͋ͬͯ Exception લఏͷίʔυ͕ॻ͔Ε͍ͯΔͱ ࠓճͷҙਤͱ͸ҧ͏λΠϛϯάͰ Break ͯ͠͠·͏ ex) .storyboard ͕ͳ͚Ε͹ .nib ʹϑΥʔϧόοΫ͢Δ try ͰΩϟον͍ͯͯ͠΋ break ͯ͠͠·͏ Exception Breakpoint Λ௥Ճ

Slide 32

Slide 32 text

Diagonostics Λઃఆ

Slide 33

Slide 33 text

•ෆਖ਼ͳϝϞϦૢ࡞Λݕ஌ •dynamic library ؔ࿈ͷϩΪϯά (dlopen, dlsym ౳) Diagonostics Λઃఆ

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Ͳ͏ઃఆ͍͍͔ͯ͠෼͔Βͳ͍…

Slide 38

Slide 38 text

ͦΜͳΈͳ͞ΜͷͨΊͷΦεεϝͷઃఆͰ͢ ɹɹ ʢXcode 7.3.1ʣ

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

ύϑΥʔϚϯε͕ؾʹͳΔ৔߹͸ Enable Address Sanitizer ΛΦϑʹͯ͠Լ͍͞

Slide 41

Slide 41 text

(lldb) po self (lldb) memory history 0x61800000e080 thread ... name = 'Memory allocated at' frame #0: 0x00000001051bba97 libclang_rt.asan_iossim_dynamic.dylib`wrap_calloc + 199 frame #1: 0x00000001064362fd libobjc.A.dylib`class_createInstance + 84 frame #2: 0x0000000106440dc7 libobjc.A.dylib`_objc_rootAlloc + 41 frame #3: 0x00000001072d6d25 UIKit`-[UIClassSwapper initWithCoder:] + 175 frame #4: 0x00000001074c731b UIKit`UINibDecoderDecodeObjectForValue + 683 ... Enable Address Sanitizer Λ༗ޮʹ͍ͯ͠Δͱ…

Slide 42

Slide 42 text

Ͳͷ ViewController ͔Θ͔Βͳ͍໰୊

Slide 43

Slide 43 text

मਖ਼ͨ͠Γػೳ௥Ճ͠Α͏ͱࢥͬͨ࣌ʹ Ͳͷ ViewController ͔Θ͔Βͳ͍ Ͳͷ ViewController ͔Θ͔Βͳ͍໰୊

Slide 44

Slide 44 text

ͦΜͳܦݧ͋Γ·ͤΜ͔ʁʁ Ͳͷ ViewController ͔Θ͔Βͳ͍໰୊

Slide 45

Slide 45 text

Ͱ͸ɺͲ͏͍͏ঢ়گͰى͜Δͷͱ͔ Ͳͷ ViewController ͔Θ͔Βͳ͍໰୊

Slide 46

Slide 46 text

• ৽͍͠ϓϩδΣΫτʹؔΘΓ࢝Ίͨ࣌ • స৬ͨ͠͹͔ͬΓͰΑ͘෼͔Βͳ͍࣌ ɹ ͳͲͳͲ… Ͳͷ ViewController ͔Θ͔Βͳ͍໰୊

Slide 47

Slide 47 text

ͱ͸͍͑ϦϞʔτͰ࡞ۀ͍ͯ͠Δͱ Ӧۀ࣌ؒ֎ʹɺΘ͟Θ͟ฉ͘ͷ΋ͳͱ… Ͳͷ ViewController ͔Θ͔Βͳ͍໰୊

Slide 48

Slide 48 text

Symbolic Breakpoint with action Λ࢖ͬͯ viewWillAppear / viewDidLoad ͕ ࣮ߦ͞ΕͨλΠϛϯάͰϩάʹදࣔ͢Δ ղܾํ๏

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

Symbolic Breakpoint ObjCͷ৔߹ viewWillApper: viewDidLoad

Slide 53

Slide 53 text

(lldb) bt 0 // suggest * thread #1: tid = 0x10503c9, 0x00000001088569f4 dealforest`ViewController.viewWillAppear(animated=false, self=0x000061800000e080) -> () + 20 at ViewController.swift:19, queue = 'com.apple.main-thread', stop reason = breakpoint 6.1 (lldb) po "[viewWillAppear] - \(self)”// custom format "[viewWillAppear] - " Action - Debugger Command

Slide 54

Slide 54 text

viewDidLoad ͱ viewWillAppear Λ ઃఆ͠ͱ͚͹େମϩάʹग़ྗ͞ΕΔ͸ͣ

Slide 55

Slide 55 text

ཧ༝ͱͯ͠͸ ViewController Ͱ ࣮૷͓͔ͯ͠ͳ͍ͱ Symbolic Breakpoint ͕ݺ͹Εͳ͍ͨΊͰ͢

Slide 56

Slide 56 text

viewDidLoad ͕ͳ͍͔΋͠Εͳ͍͠ viewWillAppear ͕ͳ͍͔΋͠Εͳ͍ Ͱ΋྆ํͳ͍ͷ͸গͳ͍͸ͣ

Slide 57

Slide 57 text

ϩά͕ᓔಃ͍͠ͱײͨ࣌͡͸ Breakpoint Λແޮʹ͢Δ͚ͩͰ͢

Slide 58

Slide 58 text

νʔϜͰڞ༗͍ͨ͠৔߹͸ Breakpoint Λڞ༗͢Δ͜ͱ͕Ͱ͖·͢

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

͓·͚

Slide 61

Slide 61 text

ͳͥ bt 0 ͕͓͢͢Ίͳͷ͔ͱ͍͏ͱ

Slide 62

Slide 62 text

Xcode Plugin - KZLinkedConsole ͱ ૬ੑ͕ͱͯ΋͍͍͔ΒͰ͢

Slide 63

Slide 63 text

krzysztofzablocki / KZLinkedConsole

Slide 64

Slide 64 text

(lldb) bt 0 * thread #1: tid = 0x10503c9, 0x00000001088569f4 dealforest`ViewController.viewWillAppear(animated=false, self=0x000061800000e080) -> () + 20 at ViewController.swift:19, queue = 'com.apple.main-thread', stop reason = breakpoint 6.1 Action - Debugger Command ϦϯΫʹͳΓλοϓ͢Δͱ։͚Δ

Slide 65

Slide 65 text

ىಈ࣌ʹಛఆͷ ViewController ʹ͍ͨ͠ ໰୊

Slide 66

Slide 66 text

ભҠ͕໘౗͍͘͞ը໘ͷػೳΛ ։ൃ͢Δ͜ͱʹͳΓ·ͨ͠ ىಈ࣌ʹಛఆͷ ViewController ʹ͍ͨ͠໰୊

Slide 67

Slide 67 text

ىಈ࣌ʹಛఆͷ ViewController ʹ͍ͨ͠໰୊

Slide 68

Slide 68 text

σόοά͢Δͱ͖ʹमਖ਼ͯ͠࠶ىಈ ͦͷޙɺը໘·ͰભҠͯ͠… ͜ΕΛ܁Γฦ͢ ىಈ࣌ʹಛఆͷ ViewController ʹ͍ͨ͠໰୊

Slide 69

Slide 69 text

ΊΜͲ͘͘͞ͳ͍Ͱ͔͢ʁʁ ىಈ࣌ʹಛఆͷ ViewController ʹ͍ͨ͠໰୊

Slide 70

Slide 70 text

Environment Variables Λ࢖͍ɹɹɹɹɹɹɹɹɹɹɹɹ ֘౰͢Δ ViewController Λදࣔ͢Δ ղܾํ๏

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

DF_STORYBOARD_NAME = Main:settings

Slide 73

Slide 73 text

දࣔ͢ΔॲཧΛdidFinishLaunchingWithOptions ʹ௥Ճ if let env = NSProcessInfo().environment["DF_STORYBOARD_NAME"] { let names = env.componentsSeparatedByString(":") if let storyboardName = names.first { let storyboard = UIStoryboard(name: storyboardName, bundle: nil) let controller: UIViewController if let identifier = names.last where identifier != storyboardName { controller = storyboard .instantiateViewControllerWithIdentifier(identifier) } else { controller = storyboard.instantiateInitialViewController()! } window?.rootViewController = controller } }

Slide 74

Slide 74 text

Xcode ͔Βىಈͨ࣌͠ͷΈ༗ޮ App Switcher Ͱ kill ͯ͠ىಈ͠ͳ͓ͤ͹ແޮʹͳΔ Environment Variables Λ࢖͏ϝϦοτ

Slide 75

Slide 75 text

Ұ࣌తͳ෼ذΛ࡞Γ͍ͨ࣌ʹ ͱͯ΋ศར

Slide 76

Slide 76 text

• ڧ੍తʹ logout • API ͷϦΫΤετઌΛมߋ • localhost:3000 • proxy • ϩάϨϕϧͷ੾Γସ͑ Environment Variables ͷ࢖͍ॴ

Slide 77

Slide 77 text

࣮ػͷϩά΍ϑΝΠϧΛऔಘ͍ͨ͠໰୊

Slide 78

Slide 78 text

ࣗલͰग़ྗ͍ͯ͠Δϩά΋͘͠͸ DBϑΝΠϧ(Realm, CoreData, SQLite…)Λ Έ͍ͨ࣌͋Γ·͢ΑͶʁ ࣮ػͷϩά΍ϑΝΠϧΛऔಘ͍ͨ͠໰୊

Slide 79

Slide 79 text

ͱ͸͍͑औಘ͠Α͏ͱࢥ͏ͱ ݁ߏΊΜͲ͍͘͞ ࣮ػͷϩά΍ϑΝΠϧΛऔಘ͍ͨ͠໰୊

Slide 80

Slide 80 text

• iExproler Λ࢖͍ iPhone ΛϚ΢ϯτ͠औಘ • PC ʹܨ͗ Xcode Ͱ Container Λऔಘɹɹɹɹ (͜ͷ৔߹ɺࣗ෼͕Ճೖ͍ͯ͠ΔνʔϜͷΞϓϦͷΈͰ͢) ࣮ػͷϩά΍ϑΝΠϧΛऔಘ͍ͨ͠໰୊

Slide 81

Slide 81 text

໘౗͍͘͞Ͱ͢Ͷ… ΋ͬͱؾܰʹ͍ͨ͠΋ͷͰ͢ ࣮ػͷϩά΍ϑΝΠϧΛऔಘ͍ͨ͠໰୊

Slide 82

Slide 82 text

LLDB Λ࢖ͬͯ֘౰͢ΔϑΝΠϧΛ Slack ΁ૹ৴ ղܾํ๏

Slide 83

Slide 83 text

DEMO

Slide 84

Slide 84 text

(lldb) slack “Documents/default.realm” Please run ‘continue’ (lldb) continue Process 25152 resuming upload success Slack ʹϑΝΠϧΛૹ৴

Slide 85

Slide 85 text

Slack Ͱड͚औͬͨ࣌ͷը૾

Slide 86

Slide 86 text

ศརͰ͠ΐʁʁ

Slide 87

Slide 87 text

࢖͍͍ͨͰ͢ΑͶʁʁ

Slide 88

Slide 88 text

https://gist.github.com/dealforest/702a848ba0a7a64b139985f5cad885f0

Slide 89

Slide 89 text

ίϚϯυΛಡΈࠐΉ $ cat ~/.lldbinit … command script import /slack.py

Slide 90

Slide 90 text

And more…

Slide 91

Slide 91 text

• Xcode Functions • memory visualizer • Xcode Plugin • LLDB • p, po, frame variable • watchpoint • facebook/chisel And more

Slide 92

Slide 92 text

• Xcode Settings - Diagonostics - Environment Variables • Breakpoint - Exception Breakpoint - Symbolic Breakpoint • LLDB Recap

Slide 93

Slide 93 text

গ͠Ͱ΋Έͳ͞ΜͷσόοάαΠΫϧ͕ɹɹɹɹ շదʹͳΕ͹޾͍Ͱ͢

Slide 94

Slide 94 text

͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠

Slide 95

Slide 95 text

͜ͷΑ͏ͳσόοάʹ·ͭΘΔ࿩Λɹɹɹɹ ମܥཱͯͯձࣾͰ࿩͢Α͏ͳ͜ͱ΋ ɹɹɹɹ ͍ͯ͠ΔͷͰڵຯ͋Δํ͸੠͕͚Լ͍͞# એ఻