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

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

Satoshi Hachiya

June 16, 2017
Tweet

More Decks by Satoshi Hachiya

Other Decks in Programming

Transcript

  1. 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 &
  2. ʢݟͨݶΓʣ΄ͱΜͲޠΒΕ͍ͯͳ͍ SwiftPM ʹ͍ͭͯ৮Ε͍ͯΔηογϣϯ • Session 102: Platforms State of the

    Union (?) • Session 402: What’s New in Swift ʢ⚠ ΄͔ʹ͝ଘ஌Ͱͨ͠Β͝ࢦఠ͍ͩ͘͞ "ʣ
  3. Platforms State of the Union Session 102 Video: [00:20:44] /

    Slides: 70 • Improved Package Manager ʢεϥΠυʹ͋Δ͕ಛʹݴٴ͸͞Ε͍ͯͳ͍ʁʣ
  4. Video: [02:25] / Slides: 7 • Growing ecosystem • 7,000+

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

    4 • New manifest API • Better development workflow, diagnostics, dependency resolution • Xcode project generation
  6. 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])
  7. 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
  8. 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
  9. 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
  10. 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
  11. PackageDescription API Version 3 Package( name: String, pkgConfig: String? =

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

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

    automaticʢ! ਪ঑ʣ • executable: ίϚϯυϥΠϯπʔϧΛ΄͔ͷύοέʔδͰ࢖͑Δ Α͏ʹ͢Δ৔߹ͷΈ
  14. 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"]), ], ...
  15. ... targets: [ .target( name: "tool", dependencies: [ "Paper", "SwiftyJSON"

    ]), .target( name: "Paper", dependencies: [ "Basic", .target(name: "Utility"), .product(name: "CHTTPParser"), ]) ] )
  16. ! ·ͩࢼ͍ͯ͠·ͤΜ " • 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
  17. 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
  18. 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
  19. ·ͱΊ • ݱঢ়͸ίϚϯυϥΠϯπʔϧ΍αʔόʔαΠυ Swift Ͱ׆༻ • ഁյతมߋ͸ͳ͘ Version 4 ΁ͷҠߦ͕εϜʔζΒ͍͠

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

    ʮSwift Package Manager (SwiftPM) Ͱ࡞ΔίϚϯυϥΠϯ πʔϧʯ@_mono • http://qiita.com/mono0926/items/e8fdd97115780204f797