Upload
make-school
View
378
Download
0
Embed Size (px)
Citation preview
DEPENDENCY MANAGEMENT
AGENDA
Introduction to Libraries & Frameworks
Dynamic vs. Static Linking
Manual Dependency Management
Cocoapods / Carthage
INTRODUCTION TO LIBRARIES & FRAMEWORKS
LIBRARIES & FRAMEWORKS
Collection of code that allows us to us pre-existing functionality
Libraries: A set of functionality that you can call when needed,
e.g. a matrix multiplication library
Frameworks: The Framework calls your code and provides
you with different extension points, e.g.: UIKit
[1] Martin Fowler on Inversion of Control
LIBRARIES & FRAMEWORKS ON IOS
Libraries: Statically linked libraries that can only contain code
but no resources
Frameworks: Dynamically linked framework that can contain
code and resource files
STATIC VS. DYNAMIC LINKING
STATIC VS. DYNAMIC LINKING
Static Linking: All dependencies are copied into the
executable of the program at compile time
Dynamic Linking: Only references to dependencies are stored
in executable. Dependencies themselves are loaded
dynamically at runtime
STATIC LINKING
Library 1 Library 2App
Reduces dependencies on the environment in which application will run
Increases app size, can’t share dependencies
Cannot update dependencies after binary has shipped
DYNAMIC LINKING
Library 1 Library 2
App
Reduces app size, libraries can be shared
Libraries can be updated after binary shipped
More uncertainty about environment in which application will run
STATIC VS. DYNAMIC ON IOS
System Frameworks (e.g. UIKit) are all linked dynamically, this
way they can be updated without resubmitting an app
Third party dependencies can be linked dynamically and statically since iOS 8, prior only static libraries were allowed
Swift code can currently only be shipped as dynamic
framework, not as static library!
MANUAL DEPENDENCY MANAGEMENT
MANUAL DEPENDENCY MANAGEMENT
Download project / add it as a Git submodule
Add project to your existing project
Add framework to project settings
MANUAL DEPENDENCY MANAGEMENT
Need to maintain dependencies of your dependencies
manually
Non-trivial to update to new versions of your dependencies
CARTHAGE / COCOAPODS
CARTHAGE / COCOAPODS
Currently the two most popular dependency managers for iOS
Allow you to define name of dependency and optionally a
version number and will resolve dependencies of your
decencies automatically
Provide simple commands to update to latest version of your
dependencies
CARTHAGE
Only supports dynamic frameworks, can only be used with
apps that ship to iOS 8.0 or later
Lightweight approach: It downloads your dependencies and
compiles the frameworks, but you still need to add them to
your project manually
COCOAPODS
Supports both dynamic frameworks and static libraries
Integrated approach: Downloads the dependencies and
restructures your project so that dependencies can be
imported right away
SUMMARY
SUMMARYLibraries allow developer to call code, frameworks call your
code and provide customization points for existing
components
Statically linked libraries are compiled as part of the host
application, dynamically linked libraries are loaded at runtime
It’s recommended to use a dependency manager on iOS -
Carthage and Cocoapods are the most popular ones
ADDITIONAL RESOURCES
ADDITIONAL RESOURCES
Blog Post: Dynamic Linking
CocoaPods Website
Carthage on GitHub