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
Swift Package Manager
Search
Konstantin
November 19, 2016
Programming
2
160
Swift Package Manager
Let’s make dependency manager great, Finally!
Konstantin
November 19, 2016
Tweet
Share
More Decks by Konstantin
See All by Konstantin
How does complier see your app
konstantinkoval
4
120
Swift rEvolution
konstantinkoval
1
230
Refactoring an Ugly Objective-C with Swift
konstantinkoval
0
210
React Native - from a mobile (iOS) developer prospective
konstantinkoval
0
61
Swift - Pushing technology limits
konstantinkoval
1
220
WatchKit
konstantinkoval
0
57
Intro in WatchKit and Watch apps
konstantinkoval
0
51
Functional Swift
konstantinkoval
1
130
I love swift.pdf
konstantinkoval
1
180
Other Decks in Programming
See All in Programming
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
9
1k
ECSのサービス間通信 4つの方法を比較する 〜Canary,Blue/Greenも添えて〜
tkikuc
11
2.3k
/←このスケジュール表に立ち向かう フロントエンド開発戦略 / A front-end development strategy to tackle a single-slash schedule.
nrslib
1
590
CSC509 Lecture 09
javiergs
PRO
0
110
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
230
Vaporモードを大規模サービスに最速導入して学びを共有する
kazukishimamoto
4
4.3k
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
1.6k
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
440
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
150
Golang と Erlang
taiyow
8
1.9k
macOS でできる リアルタイム動画像処理
biacco42
7
1.8k
offers_20241022_imakiire.pdf
imakurusu
2
360
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
RailsConf 2023
tenderlove
29
880
Art, The Web, and Tiny UX
lynnandtonic
296
20k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Why You Should Never Use an ORM
jnunemaker
PRO
53
9k
Building Better People: How to give real-time feedback that sticks.
wjessup
363
19k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.8k
Building Applications with DynamoDB
mza
90
6.1k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
Transcript
Swift Package Manager or Let’s make dependency manager great, Finally!
Kostiantyn Koval @Agens AS • Swift from day 1 •
Swift Hight Performance • Swift Package Manager • @KostiaKoval
pod install
How it used to be ! ... • Static libraries
lib.a • Copied source • Subproject + Workspace • Submodules
The problems ! • Closed code / Precompiled • Hard
to discover • No versioning • Duplicate Symbols a->c, b->c App ->(a, b) Duplicate 'c'
CocoaPods - Easy • Centralized • Podspec • Static Libs
+ Frameworks • Modifies Xcode projects + workspace Res: Workspace
Carthage - Simple • Decentralized • No Podspec • Git
+ Xcode • Frameworks Res: Frameworks
Happy
Problems • Not integrated with ! • Xcode private API
and Format • Custom scripts • Limited
SwiftPM
Why it was built? iOS Linux
SwiftPM Cross platform, Convention approach, Decentralized is a tool to
automate the process of downloading, compiling, and linking dependencies. — Swift .org
SwiftPM Fetch Build Test swift package swift build swift test
"swift package" clean Delete build artifacts describe Describe the current
package dump-package Print parsed Package.swift as JSON fetch Fetch package dependencies generate-xcodeproj Generates an Xcode project init Initialize a new package reset Reset the complete cache/build directory show-dependencies Print the resolved dependency graph update Update package dependencies
What is a Swift Package ?
What is a Swift Package ? Package.swift import PackageDescription let
package = Package( name: "Empty" )
What is a Swift Package ? • Swift, C, C++,
Objective-C, Objective-C++ One language per module • library (static, dynamic), executable, system-module
Package Convention Source in - /Sources Tests in - /Tests
Executable - main.swift Lib - SomeLib.swift C headers - /include/Baz.h
Package //executable lib with tests . . ├── Package.swift ├──
Package.swift ├── Sources ├── Sources └── main.swift │ └── Lib.swift └── Tests ├── LibTests │ └── LibTests.swift └── LinuxMain.swift
Package // 2 Modules system-module . . ├── Package.swift ├──
Package.swift └── Sources └── module.modulemap ├── A │ └── A.swift └── B └── someCode.swift
system-module // module.modulemap module Clibgit [system] { header "/usr/local/include/git2.h" link
"git2" export * }
! ship IT
Package + Git = ! • Step N1: git init,
commit, tag 0.1.0, push
Package + Git = ! • Step N2: There is
no Step N2 !
Package + Git = ! let package = Package( name:
"Empty" dependencies: [ .Package(url: "https://github.com/MyAwesomePackage", majorVersion: 0), ] ) semver, semver, semver -> Semver.org
Package Dependency let package = Package( name: "Empty" dependencies: [
.Package(url: "https://github.com/MyAwesomePackage", majorVersion: 0), .Package(url: "https://github.com/MyAwesomePackage", majorVersion: 1, minor: 4), .Package(url: "ssh://
[email protected]
/Greeter.git", versions: Version(1,0,0)..<Version(2,0,0)), .Package(url: "../StringExtensions", "1.0.0-alpha+001"), .Package(url: "../Package", version: Version(0, 1, 0), .Package(url: "../AwesomePackage", version: Version(0, 1, 0, prereleaseIdentifiers: ["alpha"], buildMetadataIdentifier: "001"), ] )
Package Power Package( name: String, dependencies: [Package.Dependency] = [], targets:
[Target] = [], exclude: [String] = [] pkgConfig: String? = nil, providers: [SystemPackageProvider]? = nil, )
Package Targets 3 Targets: Core, Network, Login . ├── Package.swift
└── Sources ├── Core │ └── core.swift ├── Login │ └── loginAPI.swift └── Network └── coreNetwork.swift
Package Targets 3 Targets: Core, Network, Login let package =
Package( name: "App", targets: [ Target(name: "Login", dependencies: ["Core", "Network"]), ] )
Package exclude let package = Package( name: "Lib", exclude: ["Sources/mocJSON",
"Sources/LibAReadme.md", "Tests/FooTests/images"] )
Package pkg-config // module.modulemap module Clibgit [system] { header "/usr/local/include/git2.h"
link "git2" export * } swift build -Xcc -I.. -Xlinker -L/usr/local/lib/
Package pkg-config swift build -Xcc -I.. -Xlinker -L/usr/local/lib/ let package
= Package( name: "Clibgit", pkgConfig: "libgit2" )
Package pkg-config swift build let package = Package( name: "Clibgit",
pkgConfig: "libgit2" )
Package pkg-config //libgit2.pc file ... Cflags: -I${includedir}/libgit2 Libs: -L${libdir} -llibgit2
What if the system package is not there? !"
Package Providers let package = Package( name: "Clibgit", pkgConfig: "libgit2",
providers: [ .Brew("libgit2"), .Apt("libgit2") ] )
Coming Soon ... Product Definitions let package = Package( name:
"MyServer", ... products: [ .Library(name: "ClientLib", type: .static, targets: ["ClientAPI"]), .Library(name: "ServerLib", type: .dynamic, targets: ["ServerAPI"]), .Executable(name: "myserver", targets: ["ServerDaemon"]), ] ) "Package Manager Product Definitions"
Xcode Integration swift package generate-xcodeproj . ├── Package.swift └── Sources
├── A │ └── A.swift └── B └── Code.swift
Xcode Integration swift package generate-xcodeproj --xcconfig-overrides Config.xcconfig . ├── Package.swift
└── Sources ├── A │ └── A.swift └── B └── Code.swift
But is it ready for Production and big Projects?
SwiftPM uses SwiftPM to "build and test" SwiftPM
SwiftPM • 19 Modules • 31 Targets • 13 Test
Modules • A lot of Code an Tests
None
It does handle the Scale
The iOS !
Does the SwiftPM solves the issue? YES!, kind off, it
will. ! • Painless config • Right Xcode project integration • Full Build & Tests control • Open Source • Many, many more ...
swift build The new -
Thanks @KostiaKoval
None