Dependency management in Xcode 11
Boris Bielik
@h3sperian
Dependency management in Xcode 11
• Swift Package
• .xcframework
• Recap
Swift Package Manager
Swift Package Manager
https://swift.org/package-manager/
Swift Package
•Open-source code only
•Platform independent
•Can be sourced locally or remotely (Github, Bitbucket, Gitlab)
•Output: Library or executable
Swift Package
• Package is defined by Package.swift manifest
• Contains source files, tests, README
• No build phases
• Currently cannot contain assets / bundles
Swift PM
Bundle and Resources
https://forums.swift.org/t/swift-pm-bundles-and-resources/13981/26
Package.swift Manifest
Publishing Swift Package
•tag based release in Github/Gitlab/Bitbucket
•follows semantic versioning - semver.org
•handle platform specific code with #if canImport()
compiler directive
•use @available() to handle platform specific versions
Integration of Swift Package
Swift Package Integration in Xcode 11
Choose Swift Package
Choose Swift Package version
Choose Your Target(s)
Swift Package Dependency
μFrameworks
Editing packages
Binary frameworks
Current state
fat framework framework Strip frameworkIntegrator
x
Binary frameworks
.xcframework
Binary framework
Multi-platform support
iOS macOs
tvOS
watchOS
iPadOS
Integration in Xcode 11
.xcframework
Integrator
How to create
binary frameworks
1. Build libraries for distribution
BUILD_LIBRARY_FOR_DISTRIBUTION=YES
2. Don’t skip installing the module
SKIP_INSTALL=NO
How to create
binary frameworks
How to create
binary frameworks
How to create
binary frameworks
How to create
binary frameworks
Binary framework
ABI Stability
since Swift 5.0
https://swift.org/blog/abi-stability-and-more/
“ABI stability is about mixing versions of Swift at run time”
Module Stability
since Swift 5.1
“Module stability is about mixing versions of Swift at compile time.”
Boris Bielik
Swift Module Interface
Swift Module Interface
Binary Distribution in Swift
Package Manager
• Currently not supported in Swift Package Manager

• Discussion thread: https://forums.swift.org/t/spm-support-for-binaries-
distribution/25549/19
Carthage supports .xcframeworks
https://github.com/Carthage/Carthage/pull/2801
CocoaPods?
https://github.com/CocoaPods/CocoaPods/issues/8892
What’s the difference
open-source
platform independent
closed-source
requires Xcode
Swift Package .xcframework
Dependency management in
Xcode 11
Dependency management in
Xcode 11
Dependency management in
Xcode 11
Dependency management in
Xcode 11
= =
Recap
•Xcode 11 brings native dependency management
•Swift Packages are first class citizens in Xcode IDE
•.xcframeworks are bundling multi-platform close-
sourced binaries
•3rd party dependency managers are still necessary
Sample project
Trailer
thanks.
Q & A
Links & materials
Adopting Swift Packages in Xcode (WWDC 2019)
Creating Swift Packages (WWDC 2019)
Binary frameworks (WWDC 2019)
Swift Package Manager
Thread: Support for binaries distribution
Micro Features Architecture for iOS

Dependency management in Xcode 11