Swift and Xcode8

  • View
    3.173

  • Download
    3

  • Category

    Software

Preview:

Citation preview

let swift(16)

스위프트�개발�환경의�변화Interface Builder, Xcode, LLDB, Instrument

OSXDEV.org허�혁

let swift(16)

Swift3?

New APIs

iOS10?�iOS9?�내년에나�써볼�수�있어요.�

그런데������������������������������������������������������������������������������������������������������������������������������������������������������������������������

New�iOS는�New�SDK로�

New�SDK는�New�Xcode로�

Xcode는�우리가�당장�쓸�수�있는�것.

Agenda

Interface Builder

Source Editing

Sanitizers

View Debugging

LLDB

Instrument

Summary

let swift(16)

Interface Builder

Interface Builder

새로운 Adaptive UI - 디바이스�타입별�렌더링�

Live preview - 디바이스�타입별

수정�하면서도�확대�축소

let swift(16)

Source Editing

Source Editing

Xcode Source Editor Extension

드디어�확장�환경�제공�

안전해�

벌써�만들어�본�사람들�

알카트라즈�플러그인�개발자들은�패닉�

번들�로딩�금지�

잘�쓰던�나도�패닉

Source Editing

새로와진�API�문서�

오프라인�API�문서�

API�문서�자동생성�

SF Mono Font

Code-signing, Provision

Source Editing

Source Editing

Source Editing

현재�라인�하이라이트

Color Literal

#colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)

Source Editing

현재�라인�하이라이트

Color Literal

#colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)

Image Literal

UIImage(#imageLiteral(resourceName: "Screen Shot"))

Source Editing

Image Literal

UIImage(#imageLiteral(resourceName: "Screen Shot"))

Source Editing

let swift(16)

Sanitizers

Sanitizers?

Sanitizers

런타임�시�버그�추적�

Swift3 / C/C++/Objective-C

컴파일�시�버그�추적은?�

Clang Static Analyzer

C/C++/Objective-C�만�지원

Sanitizers Types

AddressSanitizer - ASan

ThreadSanitizer - TSan

MemorySanitizer - MSan (LLVM)

Sanitizers Types

AddressSanitizer - ASan

ThreadSanitizer - TSan

Memory Graph Debugging

AddressSanitizer

디버깅�모드로�동작할�때�잠재적인�메모리�누수를�찾는다�

메모리�어드레스�오염�이슈를�찾는다�

이제 Swift도�지원

설정; Scheme의 Diagnostics항목

Enable Address Sanitizer

디버깅�모드로�동작할�때�잠재적인�메모리�누수를�찾는다�

메모리�어드레스�오염�이슈를�찾는다�

이제 Swift도�지원

설정; Scheme의 Diagnostics항목

Enable Address Sanitizer

AddressSanitizer

AddressSanitizer

검출�케이스�

힙,�스팩,�글로벌�버퍼�오버�플로우�

메모리�반환�후�사용�

return 후�사용�

메모리�릭

런타임�시�쓰레드에�의한�데이터�변경에�레이스�컨디션이�발생했는지를�알아낸다.�

설정; Scheme의 Diagnostics항목

Enable Thread Sanitizer

지원범위�

64비트 macOS, iOS 시뮬레이터, tvOS 시뮬레이터

watchOS와 Device는�아직�미지원

ThreadSanitizer

런타임�시�쓰레드에�의한�데이터�변경에�레이스�컨디션이�발생했는지를�알아낸다.�

설정; Scheme의 Diagnostics항목

Enable Thread Sanitizer

지원범위�

64비트 macOS, iOS 시뮬레이터, tvOS 시뮬레이터

watchOS와 Device는�아직�미지원

ThreadSanitizer

테스트�돌릴�때�옵션을�키기를�추천�

검출�케이스�

초기화�되지�않은�뮤텍스�사용�

엉뚱한�쓰레드가�언락�

쓰레드�릭�

시그널�핸들러에�안전하지�않은�함수�호출�

데이터�레이스

ThreadSanitizer

데이터�레이스�

동기화�없이�여러�쓰레드가�한�주소를�접근할�때�

그�중�하나는�읽기용�쓰레드�

끝난다면�결국�쓰레기�값이나�메모리�오염으로�

구조상�문제가�있다는�것�

혹은�동기화�작업�누락

ThreadSanitizer

Memory Graph Debugging

메모리�누수나�버려진�메모리�탐침�

디버깅�모드에서 pause된�경우

macOS, iOS 10, tvOS 10, watchOS 3 지원

Sanitizer가�켜져�있으면�동작�안함

Scheme의 Diagnostics 탭에서 Malloc Stack설정

All Allocation

Live Allocation Only

메모리�누수나�버려진�메모리�탐침�

디버깅�모드에서 pause된�경우

macOS, iOS 10, tvOS 10, watchOS 3 지원

Sanitizer가�켜져�있으면�동작�안함

Scheme의 Diagnostics 탭에서 Malloc Stack설정

All Allocation

Live Allocation Only

Memory Graph Debugging

Memory Graph Debugging

두가지�그래프�스타일�

Root Paths

참조�메모리�

얼마나�많은�메모리가�잡혀�있는지�

Cycles

메모리�누수�

누수가�어떻게�다른�누수와�연결되는지

Memory Graph Debugging

.memgraph; Plist file

저장하기�

File → Export Memory Graph

불러오기�

Open the file

디버거�프로세스가�아니라서�트레이스,�퀵룩,�po�안됨;�그래프�말고는�아무것도�안됨

let swift(16)

View Debugging

View Debugging

빨라지고�정확해짐�

클래스로�바로가기�

네비게이터에서�필터링�

오토레이아웃�디버깅

View Debugging

클래스로�바로가기

View Debugging

네비게이터에서�필터링

View Debugging

오토레이아웃�디버깅

View Debugging

오토레이아웃�디버깅

View Debugging

유한�상태�머신�Quick Look

GKStateMachine; GameplayKit를�써야…�

코드로는�알아보기�힘듬�

복잡한�동작을�그래프로�직관적으로�정의�가능�

상태별�개별�동작�

상태간�전환

유한�상태�머신�Quick Look

GKStateMachine; GameplayKit를�써야…�

코드로는�알아보기�힘듬�

복잡한�동작을�그래프로�직관적으로�정의�가능�

상태별�개별�동작�

상태간�전환

View Debugging

let swift(16)

LLDB

LLDB

스위프트 REPL도 LLDB

:<command> enables any LLDB command

LLDB

Xcode와 LLDB는�별도�프로세스로�분리�

LLDB는�죽어도 Xcode는�적당히�살아난다�

여러�버전의�디버거�지원�

디버거는�자동적�선택됨�

예를�들면 Swift 3는�가장�최신�디버거�

Swift 2.3는 Xcode 7.3.1-era 디버거

오픈소스 Swift도�매칭된�디버거를�사용하게�된다

LLDB

parray <count> <expression>

poarray <count> <expression>

자동 import

@import UIKit

settings show target.auto-import-clang-modules false

Debugger Customization

LLDB

Reusable Code $

expr let a = 3; print(a)

expr $addTwoNumbers(a: 2, b: 3)

let swift(16)

Instrument

Instrument

디버깅�시�정보�표시가�더�잘보여요.�

시스템�트레이스�

쓰레드, CPU, Point of Interest

타임�프로파일러�

앱�라이프�사이클�이벤트에�따른�동작�

메탈�시스템�트레이스…�?

let swift(16)

Demo

Demo

시간�관계�상�생략?�

개별�연락?�

샘플�프로젝트?

Summary

Interface Builder 👍

Source Editing 👍

Sanitizers 👍

LLDB 👍

Instrument 🖖

let swift(16)