Last active
February 13, 2025 00:38
-
-
Save douglashill/1bd6ba60b50315455ed2b2381bc355dc to your computer and use it in GitHub Desktop.
A minimal iOS app set up entirely in code using Objective-C rather than using a storyboard and UIApplicationSceneManifest in the Info.plist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A minimal iOS app set up entirely in code using Objective-C rather than using a storyboard and UIApplicationSceneManifest in the Info.plist. | |
// Last updated for iOS 18. | |
// Swift version: https://gist.github.com/douglashill/b8125f7e2336b6a47461df0d4898f64d | |
@import UIKit; | |
@interface SceneDelegate : UIResponder <UIWindowSceneDelegate> | |
@end | |
@implementation SceneDelegate | |
@synthesize window = _window; | |
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { | |
self.window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene]; | |
self.window.rootViewController = [[UIViewController alloc] init]; | |
[self.window makeKeyAndVisible]; | |
} | |
@end | |
@interface AppDelegate: UIResponder <UIApplicationDelegate> | |
@end | |
@implementation AppDelegate | |
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { | |
UISceneConfiguration *configuration = [[UISceneConfiguration alloc] initWithName:nil sessionRole:connectingSceneSession.role]; | |
configuration.delegateClass = SceneDelegate.class; | |
return configuration; | |
} | |
@end | |
int main(int argc, char * argv[]) { | |
return UIApplicationMain(argc, argv, nil, NSStringFromClass(AppDelegate.class)); | |
} |
Hi @stianhoiland. Thanks for the suggestion, but running from Xcode 16.0 on an iOS 18.0 iPad simulator, I find keeping the window property is still necessary for the window to appear. I don’t see any issues with indentation in this file.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't need the window property anymore. The window is retained by the scene in its windows property.
(And maybe fix the indentation of the two return statements while you're at it? :)