Skip to content

Commit 7581a51

Browse files
avijit213bot-snapci
authored andcommitted
Closes #214
GitOrigin-RevId: 2df07d204e6c0f22e756b74d9c27c2dbb98b786f
1 parent cfce1db commit 7581a51

4 files changed

Lines changed: 114 additions & 7 deletions

File tree

‎bzl/valdi/app_templates/Info.plist.tpl‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@
2727
<true/>
2828
<key>UILaunchStoryboardName</key>
2929
<string>LaunchScreen</string>
30+
<key>UIApplicationSceneManifest</key>
31+
<dict>
32+
<key>UIApplicationSupportsMultipleScenes</key>
33+
<false/>
34+
<key>UISceneConfigurations</key>
35+
<dict>
36+
<key>UIWindowSceneSessionRoleApplication</key>
37+
<array>
38+
<dict>
39+
<key>UISceneConfigurationName</key>
40+
<string>Default Configuration</string>
41+
<key>UISceneDelegateClassName</key>
42+
<string>SCValdiBootstrappingSceneDelegate</string>
43+
</dict>
44+
</array>
45+
</dict>
46+
</dict>
3047
<key>UIRequiredDeviceCapabilities</key>
3148
<array>
3249
<string>arm64</string>

‎docs/TROUBLESHOOTING.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,44 @@ error: "The selected platform is no longer supported by libc++." [-Werror,-W#war
1818
Update your project to a Valdi version with Xcode 27 support. On macOS 26 you can instead build with Xcode 26.5 and make sure Bazel uses it (see the next entry); macOS 27 can't run Xcode 26.5.
1919
</details>
2020

21+
<details id="ios-27-uiscene">
22+
<summary>iOS app exits at launch: <code>UIScene life cycle is required for apps built with this SDK</code></summary>
23+
24+
Apps built with the iOS 27 SDK must adopt the UIScene life cycle, or UIKit refuses to launch them. The full log line looks like:
25+
26+
```
27+
Application failed to launch: UIScene life cycle is required for apps built with this SDK.
28+
```
29+
30+
The default `valdi_application` setup handles this: the generated `Info.plist` declares a scene manifest whose delegate is `SCValdiBootstrappingSceneDelegate`. You need to act only if your app does one of these:
31+
32+
- **It passes its own `ios_info_plist`.** Add the scene manifest to that plist. The scene delegate builds the root view through your `SCValdiBootstrappingAppDelegate` subclass:
33+
34+
```xml
35+
<key>UIApplicationSceneManifest</key>
36+
<dict>
37+
<key>UIApplicationSupportsMultipleScenes</key>
38+
<false/>
39+
<key>UISceneConfigurations</key>
40+
<dict>
41+
<key>UIWindowSceneSessionRoleApplication</key>
42+
<array>
43+
<dict>
44+
<key>UISceneConfigurationName</key>
45+
<string>Default Configuration</string>
46+
<key>UISceneDelegateClassName</key>
47+
<string>SCValdiBootstrappingSceneDelegate</string>
48+
</dict>
49+
</array>
50+
</dict>
51+
</dict>
52+
```
53+
54+
- **Its app delegate isn't an `SCValdiBootstrappingAppDelegate`.** `SCValdiBootstrappingSceneDelegate` raises at launch because there's no bootstrapping delegate to build the root view. Use your own `UIWindowSceneDelegate` in its place: create the window in `scene:willConnectToSession:options:` with `initWithWindowScene:`, and name your class in the manifest's `UISceneDelegateClassName`.
55+
56+
Without a scene manifest, the app delegate keeps creating its window in `application:didFinishLaunchingWithOptions:` as before, which still works with SDKs before iOS 27.
57+
</details>
58+
2159
<a id="bazel-uses-the-wrong-xcode-version"></a>
2260
<details>
2361
<summary>Bazel uses the wrong Xcode version</summary>

‎valdi/src/valdi/ios/Bootstrap/SCValdiBootstrappingAppDelegate.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,15 @@
2727
*/
2828
- (UIView<SCValdiRootViewProtocol>*)createRootViewWithDependencies:(SCValdiBootstrappingDependencies*)dependencies;
2929

30+
@end
31+
32+
/**
33+
* Scene delegate for apps whose Info.plist declares a UIApplicationSceneManifest. It builds the same
34+
* window SCValdiBootstrappingAppDelegate builds without a scene, attached to the connecting UIWindowScene.
35+
* Apps built with the iOS 27 SDK must adopt the scene life cycle or they fail to launch.
36+
*/
37+
@interface SCValdiBootstrappingSceneDelegate : UIResponder <UIWindowSceneDelegate>
38+
39+
@property (strong, nonatomic) UIWindow* window;
40+
3041
@end

‎valdi/src/valdi/ios/Bootstrap/SCValdiBootstrappingAppDelegate.m‎

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
@implementation SCValdiBootstrappingDependencies
88
@end
99

10+
@interface SCValdiBootstrappingAppDelegate ()
11+
12+
- (UIViewController*)createRootViewController;
13+
14+
@end
15+
1016
@implementation SCValdiBootstrappingAppDelegate {
1117
UIWindow* _rootWindow;
1218
SCValdiRuntimeManager* _runtimeManager;
@@ -27,9 +33,23 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
2733
}
2834
}];
2935

30-
id<SCValdiRuntimeProtocol> runtime = _runtimeManager.mainRuntime;
36+
// With a scene manifest, UIKit ignores a window made here; SCValdiBootstrappingSceneDelegate makes it instead.
37+
if ([NSBundle.mainBundle objectForInfoDictionaryKey:@"UIApplicationSceneManifest"] != nil) {
38+
return YES;
39+
}
3140

3241
UIWindow* window = [UIWindow new];
42+
window.rootViewController = [self createRootViewController];
43+
[window makeKeyAndVisible];
44+
45+
_rootWindow = window;
46+
47+
return YES;
48+
}
49+
50+
- (UIViewController*)createRootViewController
51+
{
52+
id<SCValdiRuntimeProtocol> runtime = _runtimeManager.mainRuntime;
3353

3454
SCValdiDefaultNavigator* navigator = [[SCValdiDefaultNavigator alloc] initWithRuntime:runtime];
3555

@@ -46,12 +66,7 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
4666
[[UINavigationController alloc] initWithRootViewController:viewController];
4767
navigationController.navigationBar.translucent = NO;
4868

49-
window.rootViewController = navigationController;
50-
[window makeKeyAndVisible];
51-
52-
_rootWindow = window;
53-
54-
return YES;
69+
return navigationController;
5570
}
5671

5772
- (NSString*)rootValdiComponentPath
@@ -72,3 +87,29 @@ - (NSString*)rootValdiComponentPath
7287
}
7388

7489
@end
90+
91+
@implementation SCValdiBootstrappingSceneDelegate
92+
93+
- (void)scene:(UIScene*)scene
94+
willConnectToSession:(UISceneSession*)session
95+
options:(UISceneConnectionOptions*)connectionOptions
96+
{
97+
if (![scene isKindOfClass:[UIWindowScene class]]) {
98+
return;
99+
}
100+
id<UIApplicationDelegate> applicationDelegate = UIApplication.sharedApplication.delegate;
101+
if (![applicationDelegate isKindOfClass:[SCValdiBootstrappingAppDelegate class]]) {
102+
[NSException raise:NSInternalInconsistencyException
103+
format:@"SCValdiBootstrappingSceneDelegate requires an SCValdiBootstrappingAppDelegate; "
104+
@"see docs/TROUBLESHOOTING.md#ios-27-uiscene"];
105+
}
106+
107+
UIWindow* window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene*)scene];
108+
window.rootViewController =
109+
[(SCValdiBootstrappingAppDelegate*)applicationDelegate createRootViewController];
110+
[window makeKeyAndVisible];
111+
112+
self.window = window;
113+
}
114+
115+
@end

0 commit comments

Comments
 (0)