Swift Package Manager Version 4

Swift Package Manager Version 4

Otemachi.swift #01 - WWDC17 振り返り
https://nikkei.connpass.com/event/58452/

「Platforms State of the Union」
https://developer.apple.com/videos/play/wwdc2017/102/
「What's New in Swift」
https://developer.apple.com/videos/play/wwdc2017/402/

Swift Evolution
https://apple.github.io/swift-evolution/

# 参考
「実践 Swift Package Manager」@ikesyo
https://speakerdeck.com/ikesyo/shi-jian-swift-package-manager
「Swift Package Manager (SwiftPM) で作るコマンドラインツール」 @_mono
http://qiita.com/mono0926/items/e8fdd97115780204f797
「実践Server Side Swift」@noppoMan722
https://speakerdeck.com/noppoman/shi-jian-server-side-swift

# 補足記事
http://qiita.com/jpmartha/items/948a86bbb7d3e9240ce4

5eee847529e8f5ec2f634a85075fd5aa?s=128

Satoshi Hachiya

June 16, 2017
Tweet

Transcript

  1. Swift Package Manager Otemachi.swift #01 - WWDC17 ৼΓฦΓ Friday June

    16th 2017
  2. Satoshi Hachiya Twitter: @jpmartha_jp • Living in Kobe ⚓ •

    Developing an iOS app, Player! • Organizer of try! Swift Tokyo 2017 "# & try! Swift NYC 2017 $% • Speaker of MobileOptimized 2017 &
  3. WWDC ʹ͸ࢀՃ͍ͯ͠·ͤΜ͕

  4. San Jose ʹ͸ߦ͖·ͨ͠

  5. ࿩͢͜ͱ Swift Package Manager Version 4 Ͱͷมߋ಺༰

  6. Swift Package Manager (SwiftPM) ! ࢖ͬͯ·͔͢ʁ "

  7. ʢݟͨݶΓʣ΄ͱΜͲޠΒΕ͍ͯͳ͍ SwiftPM ʹ͍ͭͯ৮Ε͍ͯΔηογϣϯ • Session 102: Platforms State of the

    Union (?) • Session 402: What’s New in Swift ʢ⚠ ΄͔ʹ͝ଘ஌Ͱͨ͠Β͝ࢦఠ͍ͩ͘͞ "ʣ
  8. ͨͩ͠ ωλͱͯ͠͸ͦͷ΄͏͕޷Έ

  9. ʴ աڈͷ… ✨

  10. Ͱ͸ݟ͍͖ͯ·͠ΐ͏ !

  11. Platforms State of the Union Session 102 Video: [00:20:44] /

    Slides: 70 • Improved Package Manager ʢεϥΠυʹ͋Δ͕ಛʹݴٴ͸͞Ε͍ͯͳ͍ʁʣ
  12. What’s New in Swift Session 402

  13. Video: [02:25] / Slides: 7 • Growing ecosystem • 7,000+

    packages on GitHub • Popular for server-side Swift
  14. Video: [02:25] / Slides: 7 • Significant improvements in Swift

    4 • New manifest API • Better development workflow, diagnostics, dependency resolution • Xcode project generation
  15. Video: [10:25] / Slides: 32 • Swift package manager will

    pick the appropriate Swift version for each package let package = Package( name: "HTTP", ... swiftLanguageVersions: [3, 4])
  16. !!!!

  17. Swift Evolution https://apple.github.io/swift-evolution/ ͰݕࡧͰ͖·͢ !

  18. Swift Evolution (Implemented in Swift 4) • SE-0146 Package Manager

    Product Definitions • SE-0149 Package Manager Support for Top of Tree development • SE-0150 Package Manager Support for branches • SE-0158 Package Manager Manifest API Redesign • SE-0162 Package Manager Custom Target Layouts • SE-0175 Package Manager Revised Dependency Resolution
  19. New manifest API? • SE-0158 Package Manager Manifest API Redesign

    • https://github.com/apple/swift-evolution/blob/master/ proposals/0158-package-manager-manifest-api- redesign.md • SE-0162 Package Manager Custom Target Layouts • https://github.com/apple/swift-evolution/blob/master/ proposals/0162-package-manager-custom-target- layouts.md
  20. Better development workflow? • SE-0149 Package Manager Support for Top

    of Tree development • https://github.com/apple/swift-evolution/blob/master/ proposals/0149-package-manager-top-of-tree.md • SE-0150 Package Manager Support for branches • https://github.com/apple/swift-evolution/blob/master/ proposals/0150-package-manager-branch-support.md
  21. Better development dependency resolution? • SE-0146 Package Manager Product Definitions

    • https://github.com/apple/swift-evolution/blob/master/ proposals/0146-package-manager-product-definitions.md • SE-0175 Package Manager Revised Dependency Resolution • https://github.com/apple/swift-evolution/blob/master/ proposals/0175-package-manager-revised-dependency- resolution.md
  22. Package Manifest File Format Reference • PackageDescription API Version 3

    • PackageDescription API Version 4
  23. PackageDescription API Version 3 Package( name: String, pkgConfig: String? =

    nil, providers: [SystemPackageProvider]? = nil, targets: [Target] = [], dependencies: [Package.Dependency] = [], swiftLanguageVersions: [Int]? = nil, exclude: [String] = [] )
  24. PackageDescription API Version 4 Package( name: String, pkgConfig: String? =

    nil, providers: [SystemPackageProvider]? = nil, products: [Product] = [], dependencies: [Dependency] = [], targets: [Target] = [], swiftLanguageVersions: [Int]? = nil )
  25. products ͕૿͑ͨʢ2 typeʣ • library • static • dynamic •

    automaticʢ! ਪ঑ʣ • executable: ίϚϯυϥΠϯπʔϧΛ΄͔ͷύοέʔδͰ࢖͑Δ Α͏ʹ͢Δ৔߹ͷΈ
  26. exclude ͕ͳ͘ͳͬͨʁ • Target ͰࢦఆʢPackage Ͱ͸ͳ͘ʣ • path • excludeʢ!ʣ

    • sources • publicHeadersPath
  27. Example let package = Package( name: "Paper", products: [ .executable(name:

    "tool", targets: ["tool"]), .library(name: "Paper", targets: ["Paper"]), .library(name: "PaperStatic", type: .static, targets: ["Paper"]), .library(name: "PaperDynamic", type: .dynamic, targets: ["Paper"]), ], ...
  28. ... dependencies: [ .package(url: "http://github.com/SwiftyJSON/SwiftyJSON", from: "1.2.3"), .package(url: "../CHTTPParser", .upToNextMinor(from:

    "2.2.0")), .package(url: "http://some/other/lib", .exact("1.2.3")), ], ...
  29. ... targets: [ .target( name: "tool", dependencies: [ "Paper", "SwiftyJSON"

    ]), .target( name: "Paper", dependencies: [ "Basic", .target(name: "Utility"), .product(name: "CHTTPParser"), ]) ] )
  30. ! ·ͩࢼ͍ͯ͠·ͤΜ " • Xcode 9 beta ʹ͸ Version 4

    $ swift package --version Apple Swift Package Manager - Swift 4.0.0-dev (swiftpm-13081.9) • SwiftPM ࣗମ΋ Xcode ϓϩδΣΫτΛੜ੒Մೳ $ swift package generate-xcodeproj generated: ./SwiftPM.xcodeproj
  31. Options $ swift package --help OVERVIEW: Perform operations on Swift

    packages USAGE: swift package [options] subcommand OPTIONS: --build-path Specify build/cache directory [default: ./.build] --chdir, -C Change working directory before any other operation --disable-sandbox Disable using the sandbox when executing subprocesses --enable-prefetching Enable prefetching in resolver --verbose, -v Increase verbosity of informational output -Xcc Pass flag through to all C compiler invocations -Xlinker Pass flag through to all linker invocations -Xswiftc Pass flag through to all Swift compiler invocations --help Display available options
  32. Subcommands SUBCOMMANDS: clean Delete build artifacts describe Describe the current

    package dump-package Print parsed Package.swift as JSON edit Put a package in editable mode generate-xcodeproj Generates an Xcode project init Initialize a new package reset Reset the complete cache/build directory resolve Resolve package dependencies show-dependencies Print the resolved dependency graph tools-version Manipulate tools version of the current package unedit Remove a package from editable mode update Update package dependencies
  33. ·ͱΊ • ݱঢ়͸ίϚϯυϥΠϯπʔϧ΍αʔόʔαΠυ Swift Ͱ׆༻ • ഁյతมߋ͸ͳ͘ Version 4 ΁ͷҠߦ͕εϜʔζΒ͍͠

    • ·ͩൃల్্ʢཁௐࠪʣ • CocoaPods ΍ Carthage ͸ܧଓར༻͞Εͦ͏ • ৄࡉ͸ Swift.org ͷϝʔϦϯάϦετΛࢀর
  34. ࢀߟ • ʮ࣮ફ Swift Package Managerʯ@ikesyo • https://speakerdeck.com/ikesyo/shi-jian-swift-package- manager •

    ʮSwift Package Manager (SwiftPM) Ͱ࡞ΔίϚϯυϥΠϯ πʔϧʯ@_mono • http://qiita.com/mono0926/items/e8fdd97115780204f797
  35. ࢀߟ • ʮ࣮ફServer Side Swiftʯ@noppoMan722 • https://speakerdeck.com/noppoman/shi-jian-server-side- swift

  36. Thanks !