Skip to content

Commit 2e30968

Browse files
Xavier Jurado Cristobalfacebook-github-bot
Xavier Jurado Cristobal
authored andcommitted
Avoid crashing the app if the app delegate is written in Swift and doesn't have a window property
Summary: `window` is an optional property. If an `UIApplicationDelegate` is implemented in Swift and doesn't implement this property, the current code will crash. This was the case for NativeUIPreview's app delegate (used for [iOS Snapshot Test Previews](https://fb.workplace.com/groups/735885229793428/posts/25216903081264969/)): https://www.internalfb.com/code/fbsource/[e59804301a3c]/fbobjc/Configurations/Buck/NativeUIPreview/AppDelegate.swift?lines=6-10 This diff fixes the crash itself, although we may want to do think about a better way to get the size of the window (eg: using `UIWindowSceneDelegate` instead?). Reviewed By: LukeDefeo Differential Revision: D65665540 fbshipit-source-id: 481c76a934d07d2cdc632dbedae6fbabee3c4a9a
1 parent e160f54 commit 2e30968

File tree

1 file changed

+1
-1
lines changed
  • iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Utilities

1 file changed

+1
-1
lines changed

iOS/Plugins/FlipperKitUIDebuggerPlugin/FlipperKitUIDebuggerPlugin/Utilities/UIDSnapshot.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
// like in Split View on an iPad, the running application is
3232
// not using the entire screen thus the snapshot stretches to
3333
// fill the screen size which is incorrect.
34-
if (application.delegate.window) {
34+
if ([application.delegate respondsToSelector:@selector(window)]) {
3535
size = application.delegate.window.bounds.size;
3636
}
3737

0 commit comments

Comments
 (0)