Skip to content

Commit 0d17522

Browse files
committed
Remove dependency on FlutterAppDelegate so devs can more easily add SDKs.
1 parent 4e3be59 commit 0d17522

File tree

4 files changed

+57
-5
lines changed

4 files changed

+57
-5
lines changed

packages/flutter_tools/templates/create/ios.tmpl/Runner.xcodeproj/project.pbxproj

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
7AFFD8EF1D35381100E5BB4D /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
1011
9705A1C51CF9049000538489 /* app.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEB81CF902C7004384FC /* app.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
1112
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
1213
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -36,6 +37,8 @@
3637

3738
/* Begin PBXFileReference section */
3839
9740EEB21CF90195004384FC /* Flutter.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Flutter.xcconfig; path = Flutter/Flutter.xcconfig; sourceTree = "<group>"; };
40+
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
41+
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
3942
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
4043
9740EEB71CF902C7004384FC /* app.flx */ = {isa = PBXFileReference; lastKnownFileType = file; name = app.flx; path = Flutter/app.flx; sourceTree = "<group>"; };
4144
9740EEB81CF902C7004384FC /* app.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = app.dylib; path = Flutter/app.dylib; sourceTree = "<group>"; };
@@ -92,6 +95,8 @@
9295
97C146F01CF9000F007C117D /* Runner */ = {
9396
isa = PBXGroup;
9497
children = (
98+
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
99+
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
95100
97C146FA1CF9000F007C117D /* Main.storyboard */,
96101
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97102
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import <UIKit/UIKit.h>
2+
3+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
4+
5+
@property (strong, nonatomic) UIWindow *window;
6+
7+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#import <Flutter/Flutter.h>
2+
#include "AppDelegate.h"
3+
4+
@implementation AppDelegate
5+
6+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
7+
// Override point for customization after application launch.
8+
FlutterDartProject* project = [[FlutterDartProject alloc] initFromDefaultSourceForConfiguration];
9+
CGRect frame = [UIScreen mainScreen].bounds;
10+
UIWindow* window = [[UIWindow alloc] initWithFrame:frame];
11+
FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:project
12+
nibName:nil
13+
bundle:nil];
14+
window.rootViewController = viewController;
15+
self.window = window;
16+
[self.window makeKeyAndVisible];
17+
18+
return YES;
19+
}
20+
21+
- (void)applicationWillResignActive:(UIApplication *)application {
22+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
23+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
24+
}
25+
26+
- (void)applicationDidEnterBackground:(UIApplication *)application {
27+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
28+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
29+
}
30+
31+
- (void)applicationWillEnterForeground:(UIApplication *)application {
32+
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
33+
}
34+
35+
- (void)applicationDidBecomeActive:(UIApplication *)application {
36+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
37+
}
38+
39+
- (void)applicationWillTerminate:(UIApplication *)application {
40+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
41+
}
42+
43+
@end
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
// Copyright 2016 The Chromium Authors. All rights reserved.
2-
// Use of this source code is governed by a BSD-style license that can be
3-
// found in the LICENSE file.
4-
51
#import <UIKit/UIKit.h>
62
#import <Flutter/Flutter.h>
3+
#import "AppDelegate.h"
74

85
int main(int argc, char * argv[]) {
96
FlutterInit(argc, (const char**)argv);
107
@autoreleasepool {
118
return UIApplicationMain(argc, argv, nil,
12-
NSStringFromClass([FlutterAppDelegate class]));
9+
NSStringFromClass([AppDelegate class]));
1310
}
1411
}

0 commit comments

Comments
 (0)