0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SceneDelegate移行対応

Last updated at Posted at 2025-08-10

はじめに

wwdc2025 UIKitの新機能
でSceneベースライフサイクルを採用していない古いアプリは起動しなくなる旨の発言がありました。
TN3187: Migrating to the UIKit scene-based life cycle
を参考に進めました。
アプリ起動時に

This process does not adopt UIScene lifecycle. 
This will become an assert in a future version.

UIScene lifecycle will soon be required. 
Failure to adopt will result in an assert in the future.

といったメッセージログが表示されるアプリはsceneベースライフサイクルが適用されていないので修正が必要です。

iOS 26の次のメジャーリリース(iOS 27予定)では、Scene-basedライフサイクルを採用していないアプリは起動しなくなります。単なる警告ではなく、アプリが動作しなくなる破壊的変更です。

Info.plist

Info.plistを開いて、Application Scene Manifestを以下のように作成しました。ここはアプリごとに異なります。
infoPlist.jpg

SceneDelegateの作成とAppDelegateからの移行

AppDelegateにあるwindow変数と以下の4つのメソッドで行っている処理を移行します。

applicationDidBecomeActive(_:) -> sceneDidBecomeActive(_:)

applicationWillResignActive(_:) -> sceneWillResignActive(_:)

applicationDidEnterBackground(_:) -> sceneDidEnterBackground(_:)

applicationWillEnterForeground(_:) -> sceneWillEnterForeground(_:)

UIAlertView -> UIAlertController

UIAlertViewはiOS9.0で非推奨になりましたが、AppDelegateでは今まで通り使えていました。しかし、今回の移行でクラッシュするようになってしまったのでUIAlertControllerへの移行が必須となりました。

移行完了の確認方法

冒頭で紹介したログが表示されなければ完了です!

終わりに

WWDC 2025で発表されたScene-basedライフサイクルの必須化は、iOS開発において避けて通れない重要な変更です。一見すると面倒な作業に思えるかもしれませんが、早めにやっておくことで上記以外に対応箇所が見つかっても焦らないで済みます。(実際にUIAlertViewがクラッシュするのは移行してはじめて気づいた。)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?