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
280
猫と暮らす Google Nest Cam生活🐈 / WebRTC with Google Nest Cam
yutailang0119
0
230
Swiftの “private” を テストする / Testing Swift "private"
yutailang0119
0
270
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
750
xcrun Essentials
yutailang0119
6
1.3k
Let's Coding SwiftUI on iPad!
yutailang0119
1
540
Property Wrapperで遊ぼう / Play with Property Wrapper
yutailang0119
2
330
Other Decks in Programming
See All in Programming
GraalVM Native Image トラブルシューティング機能の最新状況(2025年版)
ntt_dsol_java
0
140
Register is more than clipboard
satorunooshie
1
470
イベントストーミングのはじめかた / Getting Started with Event Storming
nrslib
1
510
Promise.tryで実現する新しいエラーハンドリング New error handling with Promise try
bicstone
3
460
CSC509 Lecture 11
javiergs
PRO
0
310
PHPライセンス変更の議論を通じて学ぶOSSライセンスの基礎
matsuo_atsushi
0
150
TVerのWeb内製化 - 開発スピードと品質を両立させるまでの道のり
techtver
PRO
3
1k
レイトレZ世代に捧ぐ、今からレイトレを始めるための小径
ichi_raven
0
350
2025 컴포즈 마법사
jisungbin
0
130
高単価案件で働くための心構え
nullnull
0
140
JEP 496 と JEP 497 から学ぶ耐量子計算機暗号入門 / Learning Post-Quantum Crypto Basics from JEP 496 & 497
mackey0225
2
280
ゼロダウンタイムでミドルウェアの バージョンアップを実現した手法と課題
wind111
0
140
Featured
See All Featured
Optimizing for Happiness
mojombo
379
70k
Bash Introduction
62gerente
615
210k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
For a Future-Friendly Web
brad_frost
180
10k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Agile that works and the tools we love
rasmusluckow
331
21k
[RailsConf 2023] Rails as a piece of cake
palkan
57
6.1k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
1.8k
How to Think Like a Performance Engineer
csswizardry
28
2.3k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
Testing 201, or: Great Expectations
jmmastey
46
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