Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift Package Manager 3.1

Swift Package Manager 3.1

Overview of Swift Package Manager (3.1)

Joseph Heck

April 13, 2017
Tweet

More Decks by Joseph Heck

Other Decks in Technology

Transcript

  1. SWIFTPM PACKAGE MANAGER GOALS The Swift Package Manager is a

    tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. The Package Manager is included in Swift 3.0 and above. The Big Vision: ‣ https://github.com/apple/swift-package-manager/blob/master/Documentation/ PackageManagerCommunityProposal.md 2
  2. SWIFTPM WHAT IT DOES TODAY ‣ Collect dependencies based on

    a manifest ‣ Resolve dependencies ‣ Suggest how to install related dependencies with brew or apt ‣ swift build, test, and package commands ‣ Build & link C and Swift code ‣ Generate xcode project file ‣ Pass through CLI flags to llbuild/clang layers 3
  3. SWIFTPM CONSTRAINTS AND LIMITS (SWIFT 3.1) ‣ Only git for

    source control ‣ minimal fork support ‣ Limited ability to have configurable “C” builds ‣ c++ support starting in dev ‣ Minimal integration with Xcode ‣ project generation only ‣ No integration with Objective-C/IOS ‣ external package support coming in swift 4 4
  4. SWIFTPM INFLUENCES Cocoapods Carthage Javascript’s NPM Rust’s Cargo … and

    really quite a number of others - PyPi, CPAN, etc. 5
  5. SWIFTPM GETTING STARTED ▸ swift package init --type=executable ▸ .gitignore

    ▸ Package.swift ▸ Sources/main.swift ▸ Tests 6
  6. SWIFTPM DEMO & EXAMPLES ▸ (more complex) ▸ Vapor ▸

    https://github.com/vapor/vapor ▸ (simpler) ▸ Guaka ▸ https://github.com/oarrabi/Guaka 7
  7. SWIFTPM C LIBRARY EXAMPLES ▸ YAMS https://github.com/jpsim/Yams ▸ Sources/CYaml ▸

    Sources/Yams ▸ Kitura's CCurl https://github.com/IBM-Swift/CCurl ▸ Brew/apt of underlying library ▸ module.modulemap 8
  8. TEXT GUAKA heckj ~ $ git clone https://github.com/oarrabi/Guaka Cloning into

    'Guaka'... remote: Counting objects: 1095, done. remote: Compressing objects: 100% (22/22), done. remote: Total 1095 (delta 5), reused 0 (delta 0), pack-reused 1072 Receiving objects: 100% (1095/1095), 223.01 KiB | 0 bytes/s, done. Resolving deltas: 100% (621/621), done. heckj ~ Guaka master $ swift build --enable-prefetching Fetching https://github.com/oarrabi/StringScanner Cloning https://github.com/oarrabi/StringScanner Resolving https://github.com/oarrabi/StringScanner at 0.2.0 Compile Swift Module 'StringScanner' (5 sources) Compile Swift Module 'Guaka' (24 sources) heckj ~ Guaka master + $ swift package show-dependencies . !"" StringScanner<https://github.com/oarrabi/[email protected]>
  9. TEXT PACKAGE.SWIFT import PackageDescription let package = Package( name: "Guaka",

    targets: [ Target(name: "Guaka") ], dependencies: [.Package(url: "https://github.com/oarrabi/StringScanner", majorVersion: 0)] )
  10. TEXT VAPOR heckj ~ $ git clone https://github.com/vapor/vapor Cloning into

    'vapor'... remote: Counting objects: 20053, done. remote: Compressing objects: 100% (26/26), done. remote: Total 20053 (delta 7), reused 0 (delta 0), pack-reused 20027 Receiving objects: 100% (20053/20053), 8.56 MiB | 3.45 MiB/s, done. Resolving deltas: 100% (13118/13118), done. heckj ~ vapor master $ swift build --enable-prefetching Fetching https://github.com/vapor/crypto.git Fetching https://github.com/vapor/engine.git Fetching https://github.com/vapor/fluent.git Fetching https://github.com/vapor/console.git Fetching https://github.com/vapor/json.git Fetching https://github.com/stormpath/Turnstile.git … Cloning https://github.com/vapor/core.git Resolving https://github.com/vapor/core.git at 1.1.1 Cloning https://github.com/stormpath/Turnstile.git Resolving https://github.com/stormpath/Turnstile.git at 1.0.3 …
  11. TEXT VAPOR DEPENDENCIES . #"" Crypto<https://github.com/vapor/[email protected]> $ #"" Core<https://github.com/vapor/[email protected]> $

    !"" CLibreSSL<https://github.com/vapor/[email protected]> #"" Fluent<https://github.com/vapor/[email protected]> $ !"" Node<https://github.com/vapor/[email protected]> $ #"" PathIndexable<https://github.com/vapor/[email protected]> $ !"" Polymorphic<https://github.com/vapor/[email protected]> #"" Engine<https://github.com/vapor/[email protected]> $ #"" Crypto<https://github.com/vapor/[email protected]> $ $ #"" Core<https://github.com/vapor/[email protected]> $ $ !"" CLibreSSL<https://github.com/vapor/[email protected]> $ #"" TLS<https://github.com/vapor/[email protected]> $ $ #"" CLibreSSL<https://github.com/vapor/[email protected]> $ $ #"" Core<https://github.com/vapor/[email protected]> $ $ !"" Socks<https://github.com/vapor/[email protected]> $ !"" Core<https://github.com/vapor/[email protected]> #"" Console<https://github.com/vapor/[email protected]> $ #"" Polymorphic<https://github.com/vapor/[email protected]> $ !"" Core<https://github.com/vapor/[email protected]> #"" JSON<https://github.com/vapor/[email protected]> $ #"" Core<https://github.com/vapor/[email protected]> $ #"" Node<https://github.com/vapor/[email protected]> $ $ #"" PathIndexable<https://github.com/vapor/[email protected]> $ $ !"" Polymorphic<https://github.com/vapor/[email protected]> $ !"" Jay<https://github.com/DanToml/[email protected]> #"" Turnstile<https://github.com/stormpath/[email protected]> …
  12. // Console protocol and implementation for powering command line interface.

    .Package(url: "https://github.com/vapor/console.git", majorVersion: 1), // JSON enum wrapper around Foundation JSON .Package(url: "https://github.com/vapor/json.git", majorVersion: 1), // A security framework for Swift. .Package(url: "https://github.com/stormpath/Turnstile.git", majorVersion: 1), // An extensible templating language built for Vapor. .Package(url: "https://github.com/vapor/leaf.git", majorVersion: 1), // A type safe routing package including HTTP and TypeSafe routers. .Package(url: "https://github.com/vapor/routing.git", majorVersion: 1), // Parses `Content-Type: multipart` as defined in RFC 2046. .Package(url: "https://github.com/vapor/multipart.git", majorVersion: 1), ], exclude: [ "Sources/Development", "Sources/Performance", "Sources/TypeSafeGenerator" ] import PackageDescription let package = Package( name: "Vapor", targets: [ // Framework Target(name: "Vapor", dependencies: [ "Auth", "Cache", "Cookies", "Sessions", "Settings" ]), // Misc Target(name: "Auth", dependencies: ["Cookies", "Cache"]), Target(name: "Cache"), Target(name: "Cookies"), Target(name: "Sessions", dependencies: ["Cookies"]), Target(name: "Settings"), // Development and Testing // Target(name: "Development", dependencies: ["Vapor"]), // Target(name: "Performance", dependencies: ["Vapor"]), ], dependencies: [ // SHA2 + HMAC hashing. Used by the core to create session identifiers. .Package(url: "https://github.com/vapor/crypto.git", majorVersion: 1), // ORM for interacting with databases .Package(url: "https://github.com/vapor/fluent.git", majorVersion: 1), // Core vapor transport layer .Package(url: "https://github.com/vapor/engine.git", majorVersion: 1),
  13. SWIFTPM REFERENCE ▸ swift.org ▸ https://github.com/apple/swift-package-manager/blob/master/Documentation/Usage.md ▸ https://github.com/apple/swift-package-manager/blob/master/Documentation/Reference.md ▸ blogs/articles

    ▸ https://www.cocoawithlove.com/blog/package-manager-fetch.html ▸ https://www.raywenderlich.com/148832/introduction-swift-package-manager ▸ http://ankit.im/swift/2016/02/17/swift-package-manager-testing-preview/ ▸ https://oleb.net/blog/2017/03/testing-swift-packages-on-linux/ ▸ https://oleb.net/blog/2017/03/keeping-xctest-in-sync/ ▸ https://oleb.net/blog/2017/04/swift-3-1-package-manager-deployment-target/ 14
  14. SWIFTPM WHAT’S BEEN DONE ‣Swift 3 ‣swift test integration ‣https://github.com/apple/swift-evolution/blob/master/proposals/0019-package-manager-testing.md

    ‣package manager support for C languages ‣https://github.com/apple/swift-evolution/blob/master/proposals/0038-swiftpm-c-language-targets.md ‣system module search paths (Apt, Brew) ‣https://github.com/apple/swift-evolution/blob/master/proposals/0063-swiftpm-system-module-search- paths.md ‣test naming conventions ‣https://github.com/apple/swift-evolution/blob/master/proposals/0129-package-manager-test-naming- conventions.md ‣package versioning ‣https://github.com/apple/swift-evolution/blob/master/proposals/0135-package-manager-support-for- differentiating-packages-by-swift-version.md ‣Swift 3.1 ‣package edit ‣ https://github.com/apple/swift-evolution/blob/master/proposals/0082-swiftpm-package-edit.md ‣package manager version pinning ‣https://github.com/apple/swift-evolution/blob/master/proposals/0145-package-manager-version-pinning.md 15
  15. SWIFTPM WHAT’S COMING ‣ product definitions (mult deliverables per repo)

    ‣ https://github.com/apple/swift-evolution/blob/master/proposals/0146-package-manager-product- definitions.md ‣ top of tree development ‣ https://github.com/apple/swift-evolution/blob/master/proposals/0149-package-manager-top-of-tree.md ‣ packages following branches ‣ https://github.com/apple/swift-evolution/blob/master/proposals/0150-package-manager-branch-support.md ‣ package manifest API/language compatibility ‣ https://github.com/apple/swift-evolution/blob/master/proposals/0151-package-manager-swift-language- compatibility-version.md ‣ package/manifest version ‣ https://github.com/apple/swift-evolution/blob/master/proposals/0152-package-manager-tools-version.md ‣ package/manifest update ‣ https://github.com/apple/swift-evolution/blob/master/proposals/0158-package-manager-manifest-api- redesign.md ‣ package/manifest custom targets update ‣ https://github.com/apple/swift-evolution/blob/master/proposals/0162-package-manager-custom-target- layouts.md 16