Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
バックポートして学ぶ新APIの仕組み
Search
Yutaro Muta
September 11, 2022
Programming
0
3k
バックポートして学ぶ新APIの仕組み
iOSDC Japan 2022
https://fortee.jp/iosdc-japan-2022/proposal/ae6ff1d3-0777-4804-9407-5a081fba313d
Yutaro Muta
September 11, 2022
Tweet
Share
More Decks by Yutaro Muta
See All by Yutaro Muta
猫と暮らすネットワークカメラ生活🐈 ~Vision frameworkでペットを愛でよう~ / iOSDC Japan 2025
yutailang0119
0
240
猫と暮らす Google Nest Cam生活🐈 / WebRTC with Google Nest Cam
yutailang0119
0
210
Swiftの “private” を テストする / Testing Swift "private"
yutailang0119
0
260
Apple Vision Pro購入RTA 1泊3日弾丸ハワイツアー / RTA: Purchase Apple Vision Pro in Hawaii
yutailang0119
0
1.5k
個人開発のたのしみ / Enjoying personal development
yutailang0119
0
1k
Backport AsyncImage
yutailang0119
0
740
xcrun Essentials
yutailang0119
6
1.3k
Let's Coding SwiftUI on iPad!
yutailang0119
1
530
Property Wrapperで遊ぼう / Play with Property Wrapper
yutailang0119
2
330
Other Decks in Programming
See All in Programming
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
110
なぜあの開発者はDevRelに伴走し続けるのか / Why Does That Developer Keep Running Alongside DevRel?
nrslib
3
410
開発生産性を上げるための生成AI活用術
starfish719
3
1k
3年ぶりにコードを書いた元CTOが Claude Codeと30分でMVPを作った話
maikokojima
0
210
Leading Effective Engineering Teams in the AI Era
addyosmani
5
420
私達はmodernize packageに夢を見るか feat. go/analysis, go/ast / Go Conference 2025
kaorumuta
2
570
Railsだからできる 例外業務に禍根を残さない 設定設計パターン
ei_ei_eiichi
0
900
大規模アプリのDIフレームワーク刷新戦略 ~過去最大規模の並行開発を止めずにアプリ全体に導入するまで~
mot_techtalk
1
450
CSC509 Lecture 06
javiergs
PRO
0
260
登壇は dynamic! な営みである / speech is dynamic
da1chi
0
340
dynamic!
moro
10
8k
2分台で1500examples完走!爆速CIを支える環境構築術 - Kaigi on Rails 2025
falcon8823
3
3.7k
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.7k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Designing for humans not robots
tammielis
254
26k
For a Future-Friendly Web
brad_frost
180
9.9k
Producing Creativity
orderedlist
PRO
347
40k
Statistics for Hackers
jakevdp
799
220k
Into the Great Unknown - MozCon
thekraken
40
2.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
35
6.1k
Balancing Empowerment & Direction
lara
4
690
Speed Design
sergeychernyshev
32
1.2k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
8
910
Building a Modern Day E-commerce SEO Strategy
aleyda
44
7.8k
Transcript
バックポートして学ぶ 新APIの仕組み Yutaro Muta / @yutailang0119 2022/09/11 iOSDC JAPAN 2022
Who am I!? • Yutaro Muta ◦ @yutailang0119 • Hatena
Co., Ltd. ◦ @Kyoto
前置き SBPAsyncImageの紹介
yutailang0119/SBPAsyncImage • Backport of SwiftUI.AsyncImage to iOS 14, macOS 11,
tvOS 14 and watchOS 7 and earlier. • SwiftUI.AsyncImageは2021年OSから ◦ iOS 15.0+ iPadOS 15.0+ macOS 12.0+ Mac Catalyst 15.0+ tvOS 15.0+ watchOS 8.0+
SwiftUI.AsyncImage struct AsyncImage<Content> where Content : View AsyncImage(url: URL(string: “https://example.com/icon.png"))
.frame(width: 200, height: 200) BackportAsyncImage struct BackportAsyncImage<Content> where Content : View BackportAsyncImage(url: URL(string: “https://example.com/icon.png")) .frame(width: 200, height: 200)
Goal • バックポートにおける戦略の共有 ◦ SBPAsyncImageの例 • バックポートのおもしろさを発見
Agenda • なぜバックポートするのか • 新APIの調べ方 • バックポート実装のTips • メンテナンス上の難点 •
まとめ
Agenda • なぜバックポートするのか • 新APIの調べ方 • バックポート実装のTips • メンテナンス上の難点 •
まとめ
なぜバックポートするのか
なぜバックポートするのか • WWDCのアップデートは一部を除き、最新 OSにのみ提供される • アプリによっては、使えるのは数年後
なぜバックポートするのか • 例外もある • Swift Concurrency関連のAPIの一部は、 公式でバックポートされている ▪ Xcode 14.0で、URLSessionのバックポートが増えた
iOS 13.0+ iPadOS 13.0+ macOS 10.15+ Mac Catalyst 16.0+ Beta tvOS 13.0+ watchOS 6.0+ func data(from url: URL) async throws -> (Data, URLResponse)
Agenda • なぜバックポートするのか • 新APIの調べ方 • バックポート実装のTips • メンテナンス上の難点 •
まとめ
新APIの調べ方
新APIの調べ方 • Apple Developer Document ◦ API diff ◦ Technologies
• Videos • Xcode ◦ Jump to Definition ⌃⌘
Apple Developer Document
• ?changes=latest_beta • ?changes=latest_minor • ?changes=latest_major API diff
https://developer.apple.com/documentation/technologies?changes=latest_minor
新APIの調べ方 • Apple Developer Document ◦ API diff ◦ Technologies
• Videos • Xcode ◦ Jump to Definition ⌃⌘
新APIの調べ方 • Apple Developer Document ◦ API diff ◦ Technologies
• Videos • Xcode ◦ Jump to Definition ⌃⌘ 根気強く見ていく
https://yutailang0119.hatenablog.com/entry/2022/02/24/163000 宣伝 【2022年】Xcode/Apple Platform/Swiftアップデートの歩き方
Agenda • なぜバックポートするのか • 新APIの調べ方 • バックポート実装のTips • メンテナンス上の難点 •
まとめ
バックポート実装のTips
バックポート実装のTips • サポートOSの範囲 • ライブラリ、モジュールの名付け • Beta期間の取り扱い
サポートOSの範囲
サポートOSの範囲 • 2022年における基本はiOS 13+ ◦ Module Stabilityが達成されたSwift 5.1が同梱され たのがiOS 13
▪ Swift ConcurrencyのバックポートもiOS 13+ ◦ SwiftUIのAvailabilityがiOS 13+ • サポート範囲、動作の割り切りも必要 ◦ Appleも苦戦する領域
ライブラリ、 モジュールの名付け
ライブラリ、モジュールの名付け • 名前衝突を避ける工夫 • SE-0339 ◦ Module Aliasing For Disambiguation
名前衝突を避ける工夫
名前衝突を避ける工夫 • 伝統的なPrefix回避 ◦ e.g. ▪ IBP = iOS Backport
▪ SBP = Swift Backport • 冗長にバックポートとわかる名前を付ける ◦ e.g. BackportAsyncImage
SE-0339 Module Aliasing For Disambiguation
SE-0339 Module Aliasing For Disambiguation • SwiftPM 5.7+ ◦ Xcode
14.0+ • moduleAliasesキーワードで、パッケージの 外からモジュール名を変更可能 • 利用側で指定が必要
SE-0339 Module Aliasing For Disambiguation // swift-tools-version: 5.7 targets: [
.executableTarget( name: "App", dependencies: [ .product(name: "Game", package: "swift-game", moduleAliases: ["Utils": "GameUtils"]), .product(name: "Utils", package: "swift-draw"), ]) ]
Beta期間の取り扱い
Beta期間の取り扱い • Beta期間はインターフェース、挙動ともに破 壊的変更が何度も起こるものとして注視 ◦ API diff ?changes=latest_beta • 現行Stable、過去のXcodeサポートの有無
Agenda • なぜバックポートするのか • 新APIの調べ方 • バックポート実装のTips • メンテナンス上の難点 •
まとめ
メンテナンス上の難点
メンテナンス上の難点 • 小さい機能を支える広い領域 • OS毎の挙動差 • Originとの優先度
小さい機能を 支える広い領域
小さい機能を支える広い領域 • e.g. AsyncImage ◦ SwiftUI ▪ @StateObject, @ObservedObject, @Published,
ViewBuilder ◦ UIKit ▪ UIImage ◦ AppKit ▪ NSImage ◦ Foundation ▪ URLSession
OS毎の挙動差
OS毎の挙動差 • OSバージョン毎に利用できる手段の差異 ◦ iOS 14+ @StateObject ◦ iOS 13+
@ObservedObject • プラットフォーム毎にフレームワークの差異 ◦ UIKit vs AppKit ▪ e.g. UIImage vs NSImage
Originとの優先度
• 利用側にOriginとバックポート実装のどちら を優先させるか、考える必要あり Originとの優先度 Beta期間 Stable~その後 Origin @available調整 Backport 現行Xcodeのサポート
SBPAsyncImageの戦略
• AsyncImageの利用可能なOSが浸透すれば、 バックポートは役目を終えていく ◦ iOS 15+の世界 ◦ 段階的に移行させたい • Beta期間からAsyncImageを感じたい
SBPAsyncImageの戦略
• Originを優先し、移行を促す戦略 ◦ @availableを駆使 ▪ deprecated, obsoleted, unavailable • バックポート実装は独立させる戦略
◦ 利用側は別物として扱う SBPAsyncImageの戦略
• typealiasでOriginに合わせ、意識せずに利用 させる ▪ ▪ ▪ @available ▪ モジュールを指名することで、使い分け可能 @available(iOS,
deprecated: 15.0, renamed: "SwiftUI.AsyncImage") public typealias AsyncImage = BackportAsyncImage SBPAsyncImageの戦略
Agenda • なぜバックポートするのか • 新APIの調べ方 • バックポート実装のTips • メンテナンス上の難点 •
まとめ
まとめ
まとめ • バックポートには、機能開発と違う難易度、 視点、マインドがある • 2022年におけるサポートOSは最低iOS 13+ • バックポートはOriginの実装、挙動を熟知で きるのでおすすめ
References • https://github.com/yutailang0119/SBPAsyncImage • https://developer.apple.com/documentation/swiftui/asyncimage • https://developer.apple.com/documentation/foundation/urlsession/3919873-data • https://developer.apple.com/documentation •
https://developer.apple.com/documentation/technologies?changes=latest_minor • https://yutailang0119.hatenablog.com/entry/2022/02/24/163000 • https://github.com/apple/swift-evolution/blob/main/proposals/0339-module-aliasing-f or-disambiguation.md • https://developer.apple.com/documentation/packagedescription/target/dependency/pr oduct(name:package:modulealiases:) • https://docs.swift.org/swift-book/ReferenceManual/Attributes.html
Enjoy iOSDC, Thanks!!! • @yutailang0119 • yutailang0119
hatena.co.jp/recruit