From ef71a362d98b329a36dbdeed34f97b9031a909a2 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Mon, 20 Oct 2025 22:34:21 +0200 Subject: [PATCH] fix: broken swiftFileUpdater methodPrefix computation --- plugin/src/withRNOrientationAppDelegate.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugin/src/withRNOrientationAppDelegate.ts b/plugin/src/withRNOrientationAppDelegate.ts index c8b207f..ddbcd90 100644 --- a/plugin/src/withRNOrientationAppDelegate.ts +++ b/plugin/src/withRNOrientationAppDelegate.ts @@ -59,7 +59,7 @@ export function swiftFileUpdater( originalContents: string, sdkVersion?: string ): string { - const methodPrefix = !sdkVersion?.includes('53') ? 'override' : ''; + const methodPrefix = computeMethodPrefix(sdkVersion); const supportedInterfaceOrientationsForCodeBlock = `\n ${methodPrefix} func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return OrientationDirector.getSupportedInterfaceOrientationsForWindow() }\n`; @@ -77,6 +77,24 @@ export function swiftFileUpdater( }); return results.contents; + + function computeMethodPrefix(_sdkVersion?: string) { + if (!_sdkVersion) { + return ''; + } + + const sdkVersionAsNumber = Number(_sdkVersion); + if (Number.isNaN(sdkVersionAsNumber)) { + return ''; + } + + if (sdkVersionAsNumber >= 53) { + return ''; + } + + // Older SDK versions need the override keyword + return 'override'; + } } export function objCFileUpdater(originalContents: string): string {