Slide 1

Slide 1 text

Simplify your life: build apps from reusable libraries

Slide 2

Slide 2 text

Julia Vashchenko C++ macOS developer

Slide 3

Slide 3 text

–Steve McConnell, 'Code Complete' “Managing complexity is the most important technical topic in software development.”

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Versus Quiz

Slide 8

Slide 8 text

Versus Quiz

Slide 9

Slide 9 text

Library Framework

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Inversion of Control Conceptual difference Martin Fowler on Frameworks and Inversion of Control:

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

FRAMEWORK CONTROLS YOU

Slide 17

Slide 17 text

Library Framework Technical difference

Slide 18

Slide 18 text

Library Framework Technical difference

Slide 19

Slide 19 text

Explicit Dependencies in Xcode Implicit

Slide 20

Slide 20 text

Explicit Dependencies

Slide 21

Slide 21 text

Implicit Dependencies

Slide 22

Slide 22 text

Static Dynamic libraries

Slide 23

Slide 23 text

Static Dynamic

Slide 24

Slide 24 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows

Slide 25

Slide 25 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows

Slide 26

Slide 26 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary

Slide 27

Slide 27 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary

Slide 28

Slide 28 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger

Slide 29

Slide 29 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger smaller

Slide 30

Slide 30 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger smaller Application Load Time slower

Slide 31

Slide 31 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger smaller Application Load Time slower faster

Slide 32

Slide 32 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger smaller Application Load Time slower faster Binding Symbols at link time

Slide 33

Slide 33 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger smaller Application Load Time slower faster Binding Symbols at link time at run time

Slide 34

Slide 34 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger smaller Application Load Time slower faster Binding Symbols at link time at run time Library Update Mechanism rebuild host application

Slide 35

Slide 35 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger smaller Application Load Time slower faster Binding Symbols at link time at run time Library Update Mechanism rebuild host application updates separately

Slide 36

Slide 36 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger smaller Application Load Time slower faster Binding Symbols at link time at run time Library Update Mechanism rebuild host application updates separately Usage in Playgrounds can't be used

Slide 37

Slide 37 text

Static Dynamic File extension .a on Linux, macOS, iOS .lib on Windows .dylib on macOS, iOS .so on Linux .dll on Windows Compilation INTO binary OUTSIDE the binary Binary Size bigger smaller Application Load Time slower faster Binding Symbols at link time at run time Library Update Mechanism rebuild host application updates separately Usage in Playgrounds can't be used is used

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

LLVM Clang

Slide 40

Slide 40 text

compiler backend compiler frontend LLVM Clang

Slide 41

Slide 41 text

C, C++, Objective-C, Objective-C++ LLVM Clang

Slide 42

Slide 42 text

ActionScript, Ada, C, C#, C++, Common Lisp, Crystal, CUDA, D, Delphi, Fortran, Graphical G Programming Language, Halide, Haskell, Java bytecode, Julia, Kotlin, Lua, Objective-C, OpenGL Shading Language, Pony, Python, R, Ruby, Rust, Scala, Swift, Xojo LLVM Clang C, C++, Objective-C, Objective-C++

Slide 43

Slide 43 text

ActionScript, Ada, C, C#, C++, Common Lisp, Crystal, CUDA, D, Delphi, Fortran, Graphical G Programming Language, Halide, Haskell, Java bytecode, Julia, Kotlin, Lua, Objective-C, OpenGL Shading Language, Pony, Python, R, Ruby, Rust, Scala, Swift, Xojo LLVM Clang C, C++, Objective-C, Objective-C++

Slide 44

Slide 44 text

Compiling Linking

Slide 45

Slide 45 text

Compiling Linking +

Slide 46

Slide 46 text

Compiling Linking + Headers ↓

Slide 47

Slide 47 text

Compiling Linking + Headers Object files ↓ ↓

Slide 48

Slide 48 text

#include #import @import

Slide 49

Slide 49 text

Modules

Slide 50

Slide 50 text

What languages support modules?

Slide 51

Slide 51 text

C++ Ada Julia Swift JavaScript Objective-C Python IBM/360 Assembler Perl C# Haskell Ruby Pascal Turbo Pascal Clojure Java

Slide 52

Slide 52 text

C++ Ada Julia Swift JavaScript Objective-C Python IBM/360 Assembler Perl C# Haskell Ruby Pascal Turbo Pascal Clojure Java

Slide 53

Slide 53 text

C++ Ada Julia Swift JavaScript Objective-C Python IBM/360 Assembler Perl C# Haskell Ruby Pascal Turbo Pascal Clojure Java

Slide 54

Slide 54 text

Swift module Clang module

Slide 55

Slide 55 text

Swift module Clang module

Slide 56

Slide 56 text

Swift module Clang module

Slide 57

Slide 57 text

How to manage lib updates

Slide 58

Slide 58 text

How to manage lib updates • do not manage

Slide 59

Slide 59 text

How to manage lib updates • do not manage • via Swift Package Manager: depend on private repo

Slide 60

Slide 60 text

How to manage lib updates • do not manage • via Swift Package Manager: depend on private repo • via CocoaPods: Private Pod

Slide 61

Slide 61 text

How to manage lib updates • do not manage • via Swift Package Manager: depend on private repo • via CocoaPods: Private or Local Pod • via Git Submodule

Slide 62

Slide 62 text

Swift Package Manager Using GitHub Deploy Key Package.swift: Type in Terminal:

Slide 63

Slide 63 text

Swift Package Manager Using GitHub Deploy Key Config file contents: GitHub.com → Your Profile → Repositories → Settings → Deploy Keys → Add deploy key → paste public key → check ‘Allow write access’

Slide 64

Slide 64 text

CocoaPods Using Private&Local Pods

Slide 65

Slide 65 text

CocoaPods Using Private&Local Pods 17:30 Modularizing your iOS apps

Slide 66

Slide 66 text

Git Submodules

Slide 67

Slide 67 text

Git Submodules

Slide 68

Slide 68 text

Building Swift module in Xcode

Slide 69

Slide 69 text

Building Swift module in Xcode

Slide 70

Slide 70 text

Building Swift module without Xcode

Slide 71

Slide 71 text

Building Swift module without Xcode

Slide 72

Slide 72 text

Demo: Making & Using a Framework

Slide 73

Slide 73 text

Troubleshooting common problems

Slide 74

Slide 74 text

Error type Check: Compilation error HEADER_SEARCH_PATHS Xcode doesn’t build subproject Implicit Dependencies in ‘Schemes’ should be checked Linker error 1. Is there a function with exact name? 2. Is is implemented? Xcode can’t find a built library LIBRARIES_SEARCH_PATHS Static library doesn’t work for simulator Use lipo tool to add missing architecture

Slide 75

Slide 75 text

Thank you [email protected]