UIKITとCORE DATAを使ったSWIFTモバイルアプリ開発の基本
毎年恒例ですがiOS26対応しました。
以下、やったこと
・方針
Xcode26対応をするのが目的なので以下2つはやらない
・Liquid Glass対応
・Swift6対応
あとでぽちぽちやるかなぁ・・・・
・Liquid Glassを無効にする
UIDesignRequiresCompatibilityをtrue
https://note.amazia.co.jp/n/na31add638239
・SceneDelegate対応
>UIScene lifecycle will soon be required. Failure to adopt will result in an assert in the future.
いつの間にか更新されたらしい
https://qiita.com/Ritsuya/items/d7a697cf4648898bf405
https://product.st.inc/entry/2025/09/29/174637
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
let sceneConfiguration = UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
sceneConfiguration.delegateClass = SceneDelegate.self
return sceneConfiguration
}
final class SceneDelegate: NSObject, UIWindowSceneDelegate {
func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
//ここでstoryboardを初期化する
}
}
・Swift6対応
以下の設定を入れることで制御できる
まずは除外対応を入れる
SWIFT_STRICT_CONCURRENCY = minimal;
SWIFT_VERSION = 5.0;
https://qiita.com/garyuu09/items/6171465e98bd0e965ce4
・mobile SDKを12に上げる
https://developers.google.com/admob/ios/migration?hl=ja#migrate-to-sdk-v12
//1. //接頭辞のGADを消す //2. //old GADMobileAds.sharedInstance().start() //new MobileAds.shared.start() //3. //old GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth) //new currentOrientationAnchoredAdaptiveBanner(width: viewWidth)
・Swift6対応
やらないといいつつちょっとだけ
//old @UIApplicationMain //new @main
・’onChange(of:perform:)’ was deprecated in iOS 17.0: Use onChange with a two or zero parameter action closure instead.
//old
.onChange(of: value) { newValue in
// 処理
}
//new
.onChange(of: value) {
// 処理
}
UIKITとCORE DATAを使ったSWIFTモバイルアプリ開発の基本