From 7a84223841194ad7e94b2c3c717f948cc01228d0 Mon Sep 17 00:00:00 2001 From: joywayer Date: Sun, 21 Jun 2026 20:03:33 +0800 Subject: [PATCH] =?UTF-8?q?M0=EF=BC=9A=E9=A1=B9=E7=9B=AE=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=B0=B1=E7=BB=AA=EF=BC=88=E6=A8=AA=E5=B1=8F?= =?UTF-8?q?=E9=94=81=E5=AE=9A=E3=80=81Swift=206=E3=80=81=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 锁定 iPhone/iPad 仅横屏(LandscapeLeft/Right),契合 H5 端 1280×720 设计分辨率;UIRequiresFullScreen=true 防 iPad 多任务下方向不锁 - Swift Language Version 升到 6.0(配合已启用的 Approachable Concurrency + MainActor 默认隔离) - 删除默认 Main.storyboard / ViewController.swift 模板, 改用 SceneDelegate 代码创建 RootViewController 启动, Build Settings 同步清空 INFOPLIST_KEY_UIMainStoryboardFile - Info.plist 补齐契约项 UIStatusBarHidden=NO、 UIViewControllerBasedStatusBarAppearance=YES,配合 AppDelegate 启动时设置 applicationSupportsShakeToEdit=true 覆盖契约 §4.2.1 摇一摇前置 - BuildProject 通过验证 --- ylgamehall.xcodeproj/project.pbxproj | 22 ++++++------ ylgamehall/AppDelegate.swift | 31 +++++------------ ylgamehall/Base.lproj/Main.storyboard | 24 ------------- ylgamehall/Info.plist | 8 +++-- ylgamehall/RootViewController.swift | 26 ++++++++++++++ ylgamehall/SceneDelegate.swift | 49 +++++---------------------- ylgamehall/ViewController.swift | 19 ----------- 7 files changed, 62 insertions(+), 117 deletions(-) delete mode 100644 ylgamehall/Base.lproj/Main.storyboard create mode 100644 ylgamehall/RootViewController.swift delete mode 100644 ylgamehall/ViewController.swift diff --git a/ylgamehall.xcodeproj/project.pbxproj b/ylgamehall.xcodeproj/project.pbxproj index a9085af..4f54316 100644 --- a/ylgamehall.xcodeproj/project.pbxproj +++ b/ylgamehall.xcodeproj/project.pbxproj @@ -150,9 +150,10 @@ INFOPLIST_FILE = ylgamehall/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; - INFOPLIST_KEY_UIMainStoryboardFile = Main; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UIMainStoryboardFile = ""; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -165,7 +166,7 @@ SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -182,9 +183,10 @@ INFOPLIST_FILE = ylgamehall/Info.plist; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; - INFOPLIST_KEY_UIMainStoryboardFile = Main; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UIMainStoryboardFile = ""; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -197,7 +199,7 @@ SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; - SWIFT_VERSION = 5.0; + SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -255,7 +257,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 26.5; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -313,7 +315,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 26.5; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; diff --git a/ylgamehall/AppDelegate.swift b/ylgamehall/AppDelegate.swift index c5cbe90..bada79e 100644 --- a/ylgamehall/AppDelegate.swift +++ b/ylgamehall/AppDelegate.swift @@ -2,35 +2,22 @@ // AppDelegate.swift // ylgamehall // -// Created by Joywayer on 2026/6/21. -// import UIKit @main -class AppDelegate: UIResponder, UIApplicationDelegate { +final class AppDelegate: UIResponder, UIApplicationDelegate { - - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. + func application(_ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + application.applicationSupportsShakeToEdit = true return true } - // MARK: UISceneSession Lifecycle - - func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { - // Called when a new scene session is being created. - // Use this method to select a configuration to create the new scene with. - return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + func application(_ application: UIApplication, + configurationForConnecting connectingSceneSession: UISceneSession, + options: UIScene.ConnectionOptions) -> UISceneConfiguration { + UISceneConfiguration(name: "Default Configuration", + sessionRole: connectingSceneSession.role) } - - func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { - // Called when the user discards a scene session. - // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. - // Use this method to release any resources that were specific to the discarded scenes, as they will not return. - } - - } - diff --git a/ylgamehall/Base.lproj/Main.storyboard b/ylgamehall/Base.lproj/Main.storyboard deleted file mode 100644 index 25a7638..0000000 --- a/ylgamehall/Base.lproj/Main.storyboard +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ylgamehall/Info.plist b/ylgamehall/Info.plist index dd3c9af..9246d9d 100644 --- a/ylgamehall/Info.plist +++ b/ylgamehall/Info.plist @@ -15,11 +15,15 @@ Default Configuration UISceneDelegateClassName $(PRODUCT_MODULE_NAME).SceneDelegate - UISceneStoryboardFile - Main + UIRequiresFullScreen + + UIStatusBarHidden + + UIViewControllerBasedStatusBarAppearance + diff --git a/ylgamehall/RootViewController.swift b/ylgamehall/RootViewController.swift new file mode 100644 index 0000000..879f67a --- /dev/null +++ b/ylgamehall/RootViewController.swift @@ -0,0 +1,26 @@ +// +// RootViewController.swift +// ylgamehall +// +// M0 阶段临时根控制器,后续将被 Coordinator + LobbyViewController 替换。 +// + +import UIKit + +final class RootViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + view.backgroundColor = .black + } + + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + .landscape + } + + override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { + .landscapeRight + } + + override var prefersStatusBarHidden: Bool { false } +} diff --git a/ylgamehall/SceneDelegate.swift b/ylgamehall/SceneDelegate.swift index 5cc4da6..d57b0c9 100644 --- a/ylgamehall/SceneDelegate.swift +++ b/ylgamehall/SceneDelegate.swift @@ -2,51 +2,20 @@ // SceneDelegate.swift // ylgamehall // -// Created by Joywayer on 2026/6/21. -// import UIKit -class SceneDelegate: UIResponder, UIWindowSceneDelegate { +final class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? - - func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { - // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. - // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. - // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). - guard let _ = (scene as? UIWindowScene) else { return } + func scene(_ scene: UIScene, + willConnectTo session: UISceneSession, + options connectionOptions: UIScene.ConnectionOptions) { + guard let windowScene = scene as? UIWindowScene else { return } + let window = UIWindow(windowScene: windowScene) + window.rootViewController = RootViewController() + self.window = window + window.makeKeyAndVisible() } - - func sceneDidDisconnect(_ scene: UIScene) { - // Called as the scene is being released by the system. - // This occurs shortly after the scene enters the background, or when its session is discarded. - // Release any resources associated with this scene that can be re-created the next time the scene connects. - // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). - } - - func sceneDidBecomeActive(_ scene: UIScene) { - // Called when the scene has moved from an inactive state to an active state. - // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. - } - - func sceneWillResignActive(_ scene: UIScene) { - // Called when the scene will move from an active state to an inactive state. - // This may occur due to temporary interruptions (ex. an incoming phone call). - } - - func sceneWillEnterForeground(_ scene: UIScene) { - // Called as the scene transitions from the background to the foreground. - // Use this method to undo the changes made on entering the background. - } - - func sceneDidEnterBackground(_ scene: UIScene) { - // Called as the scene transitions from the foreground to the background. - // Use this method to save data, release shared resources, and store enough scene-specific state information - // to restore the scene back to its current state. - } - - } - diff --git a/ylgamehall/ViewController.swift b/ylgamehall/ViewController.swift deleted file mode 100644 index c7d6962..0000000 --- a/ylgamehall/ViewController.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// ViewController.swift -// ylgamehall -// -// Created by Joywayer on 2026/6/21. -// - -import UIKit - -class ViewController: UIViewController { - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view. - } - - -} -