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

Road to Swift 6

Road to Swift 6

Avatar for yuki shinohara

yuki shinohara

July 16, 2024
Tweet

More Decks by yuki shinohara

Other Decks in Technology

Transcript

  1. Introduction Name: 篠原 裕貴
 Work: 株式会社マネーフォワード > マネーフォワードビジ ネスカンパニー >

    ERP開発本部 > 福岡第一開発部 > Warriorグループ > モバイルアプリ開発チーム 
 Career: 公務員 > ワーホリ > 英会話講師 > iOSエンジニア 
 Hobbies: ランニング、柴犬、アニメ 
 

  2. もうすぐSwift 6がやってくる ❏ 7/10時点でのSwift最新バージョン 5.10.1 ❏ Xcode16 betaをインストールするとSwift 6を使うことができる ❏

    データ競合がなくなってアプリのパフォーマンスが上がる 今のコードベースだ とBuildしない可能 性が💥
  3. もうすぐSwift 6がやってくる ❏ 7/10時点でのSwift最新バージョン 5.10.1 ❏ Xcode16 betaをインストールするとSwift 6を使うことができる ❏

    データ競合がなくなってアプリのパフォーマンスが上がる データ競合を起こす可能性の あるコードは全てビルドエラー になってしまう
  4. Strict Concurrency Checking ❏ Start to emit warning about code

    that is not able to conform to concurrency safe
  5. ❏ グローバル変数 ❏ どこからでも読み書きできる → データ競合🔥 Var 'XXX' is not

    concurrency-safe because it is non-isolated global shared mutable state; WWDC24. 「Swift 6へのアプリの移行」 . https://developer.apple.com/jp/videos/play/wwdc2024/10169/, (参照 2024-7-11)
  6. ❏ グローバル変数 ❏ 定数にする: var → let ❏ @MainActorを付与する ❏

    nonisolated(unsafe)を付与する Var 'XXX' is not concurrency-safe because it is non-isolated global shared mutable state; WWDC24. 「Swift 6へのアプリの移行」 . https://developer.apple.com/jp/videos/play/wwdc2024/10169/, (参照 2024-7-11)
  7. ❏ Call a main actor isolated class method from sync

    nonisolated context ❏ Concurrencyを使えるようにasyncを追加する or Task で囲む ❏ @MainActorをメソッドに付与する ❏ 呼び出し側もMainActorで呼び出す必要がある Call to actor-isolated instance method in a synchronous actor-isolated context WWDC24. 「Swift 6へのアプリの移行」 . https://developer.apple.com/jp/videos/play/wwdc2024/10169/, (参照 2024-7-11)
  8. Call to actor-isolated instance method in a synchronous actor-isolated context

    ❏ Call a main actor isolated class method from sync nonisolated context ❏ Concurrencyを使えるようにasyncを追加する or Task で囲む ❏ @MainActorをメソッドに付与する ❏ 呼び出し側もMainActorで呼び出す必要がある WWDC24. 「Swift 6へのアプリの移行」 . https://developer.apple.com/jp/videos/play/wwdc2024/10169/, (参照 2024-7-11)
  9. ❏ Needs to be called from methods on the main

    actor ❏ ContentView: MainActor ❏ Extension: Call to actor-isolated instance method in a synchronous actor-isolated context WWDC24. 「Swift 6へのアプリの移行」 . https://developer.apple.com/jp/videos/play/wwdc2024/10169/, (参照 2024-7-11)
  10. ❏ Needs to be called from methods on the main

    actor ❏ ContentView: MainActor ❏ Extension: Call to actor-isolated instance method in a synchronous actor-isolated context WWDC24. 「Swift 6へのアプリの移行」 . https://developer.apple.com/jp/videos/play/wwdc2024/10169/, (参照 2024-7-11)
  11. MainActor-isolated instance method “XXX” cannot be used to satisfy noisolated

    protocol requirement ❏ nonisolatedをメソッドに付与する ❏ アクターからの孤立ルールから除外する (よくない) →仕方ないケース ❏ @MainActorをDelegateにつける WWDC24. 「Swift 6へのアプリの移行」 . https://developer.apple.com/jp/videos/play/wwdc2024/10169/, (参照 2024-7-11)
  12. ❏ @preconcurrencyだけでok MainActor-isolated instance method “XXX” cannot be used to

    satisfy noisolated protocol requirement WWDC24. 「Swift 6へのアプリの移行」 . https://developer.apple.com/jp/videos/play/wwdc2024/10169/, (参照 2024-7-11)
  13. Callback and completionHandler ❏ Not mentioned about the queue: non-isolated.

    Cannot access the isolated data ❏ Mentioned: guaranteed WWDC24. 「Swift 6へのアプリの移行」 . https://developer.apple.com/jp/videos/play/wwdc2024/10169/, (参照 2024-7-11)