WWDC Recap - Binary Framework in Swift

WWDC Recap - Binary Framework in Swift

Binary Framework in Swift
- ABI Stability
- Module Stability
- XCFramework
- Swift Package Manager

9bf923e39671cde83584e3e926296c13?s=128

Kishikawa Katsumi

June 17, 2019
Tweet

Transcript

  1. Binary Framework in Swift https://developer.apple.com/videos/play/wwdc2019/416/

  2. Binary Framework in Swift • ABI Stability • Module Stability

    • XCFramework • Swift Package Manager
  3. Swift 5.0 ABI Stability

  4. Swift 5.1 Module Stability

  5. Module Stability • Ϟδϡʔϧ͕҆ఆʢมΘΓʹ͍͘ʣͰ͋Δ • ʹʹϞδϡʔϧʹޓ׵ੑ͕͋Δ • ʹʹҟͳΔόʔδϣϯͷίϯύΠϥ͔Βੜ੒͞ΕͨϞδϡʔϧΛղऍͰ ͖Δ •

    ʹʹҟͳΔόʔδϣϯͷίϯύΠϥ͔Βੜ੒͞ΕͨϞδϡʔϧΛΠϯ ϙʔτͰ͖Δ
  6. Module Stability

  7. Module Stability

  8. Module Stability

  9. Module Stability • Swift 5.1ະຬͷSwift͸ɺҟͳΔόʔδϣϯͷίϯύΠϥ͔Βੜ੒͞ΕͨϞ δϡʔϧʢʹswiftmoduleʣΛImportͰ͖ͳ͍

  10. Module Stability Swift Module Interfaces

  11. Swift Module Interfaces

  12. Swift Module Interfaces

  13. Swift Module Interfaces

  14. Swift Module Interfaces // swift-interface-format-version: 1.0 // swift-tools-version: Apple Swift

    version 5.1 effective-4.2 (swiftlang-1100.0.38.29 clang-1100.0.20.14) // swift-module-flags: -target x86_64-apple-ios12.1-simulator -enable-objc-interop -enable-library-evolution -swift-version 4.2 -enforce-exclusivity=checked -Onone -module-name A @_exported import A import Foundation import Swift public struct A { public init() public func f() }
  15. https://forums.swift.org/t/plan-for-module-stability/14551

  16. ABI Stability • ABI == όΠφϦؒͷΠϯλʔϑΣʔε • ؔ਺ݺͼग़͠ن໿ • ωʔϜϚϯάϦϯά

    • ϝϞϦϨΠΞ΢τ • ͦͷଞϝλσʔλ • etc.
  17. ABI Stability • ҟͳΔόʔδϣϯͷίϯύΠϥͰੜ੒͞ΕͨόΠφϦʢ㲈ϥΠϒϥϦʣͱ ϦϯΫ͢Δ͜ͱ͕Ͱ͖Δ

  18. ABI Stability

  19. ABI Stability

  20. ABI Stability • @frozen enum • @frozen struct • @inlinable

    functions • @usableFromInline
  21. ABI Stability

  22. ABI Stability • @frozen΍@inlinableΛ෇͚ΔલʹύϑΥʔϚϯεΛܭଌ͠·͠ΐ͏ʂ

  23. Swift 5.1 XCFramework

  24. XCFramework xcodebuild archive \ -scheme KeychainAccess \ -destination 'generic/platform=iOS' \

    -destination 'generic/platform=iOS Simulator' \ -destination 'generic/platform=watchOS' \ -destination 'generic/platform=watchOS Simulator' \ -destination 'generic/platform=tvOS' \ -destination 'generic/platform=tvOS Simulator' \ -destination 'platform=OS X,arch=x86_64' \ SKIP_INSTALL=NO
  25. XCFramework

  26. xcodebuild archive \ -scheme KeychainAccess \ -destination 'generic/platform=iOS' \ -archivePath

    ./KeychainAccess-iOS \ SKIP_INSTALL=NO xcodebuild archive \ -scheme KeychainAccess \ -destination 'generic/platform=iOS Simulator' \ -archivePath ./KeychainAccess-iOS-Simulator \ SKIP_INSTALL=NO xcodebuild archive \ -scheme KeychainAccess \ -destination 'generic/platform=watchOS' \ -archivePath ./KeychainAccess-watchOS \ SKIP_INSTALL=NO ...
  27. XCFramework

  28. xcodebuild -create-xcframework \ -framework ./KeychainAccess-iOS.xcarchive/Products/Library/Frameworks/KeychainAccess.framework \ -framework ./KeychainAccess-iOS-Simulator.xcarchive/Products/Library/Frameworks/KeychainAccess.framework \ -framework

    ./KeychainAccess-watchOS.xcarchive/Products/Library/Frameworks/KeychainAccess.framework \ -framework ./KeychainAccess-watchOS-Simulator.xcarchive/Products/Library/Frameworks/KeychainAccess.framework \ -framework ./KeychainAccess-tvOS.xcarchive/Products/Library/Frameworks/KeychainAccess.framework \ -framework ./KeychainAccess-tvOS-Simulator.xcarchive/Products/Library/Frameworks/KeychainAccess.framework \ -framework ./KeychainAccess-macOS.xcarchive/Products/Library/Frameworks/KeychainAccess.framework \ -output KeychainAccess.xcframework XCFramework
  29. XCFramework

  30. XCFramework

  31. Swift Package Manager

  32. Swift Package Manager

  33. Swift Package Manager

  34. Swift Package Manager

  35. Swift Package Manager

  36. SPM & XCFramework • OSSϥΠϒϥϦʹ͓͍ͯ͸SPMͰಋೖ͢Δ΄͏͕ϝϦοτ͕ଟ͍ • ґଘղܾ • όʔδϣϯ؅ཧ •

    Package.swiftΛஔ͚ͩ͘ • XCFramework͸౰໘ϕϯμʔϥΠϒϥϦʹ࢖ΘΕΔͷͰ͸
  37. SPM & XCFramework • CarthageͷDistribution͕XCFrameworkʹͳΔͷ͸͘͢͝ศར • ηοτΞοϓ͕؆୯ʢυϥοάˍυϩοϓ͢Δ͚ͩʣ • copy-frameworks͕ෆཁʹͳΔ