Skip to content

Commit 1142126

Browse files
authored
fix: expo plugin breaking due to override keyword not supported in version 54 (#92)
1 parent a50866c commit 1142126

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

plugin/src/withRNOrientationAppDelegate.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function swiftFileUpdater(
5959
originalContents: string,
6060
sdkVersion?: string
6161
): string {
62-
const methodPrefix = !sdkVersion?.includes('53') ? 'override' : '';
62+
const methodPrefix = computeMethodPrefix(sdkVersion);
6363
const supportedInterfaceOrientationsForCodeBlock = `\n ${methodPrefix} func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
6464
return OrientationDirector.getSupportedInterfaceOrientationsForWindow()
6565
}\n`;
@@ -77,6 +77,24 @@ export function swiftFileUpdater(
7777
});
7878

7979
return results.contents;
80+
81+
function computeMethodPrefix(_sdkVersion?: string) {
82+
if (!_sdkVersion) {
83+
return '';
84+
}
85+
86+
const sdkVersionAsNumber = Number(_sdkVersion);
87+
if (Number.isNaN(sdkVersionAsNumber)) {
88+
return '';
89+
}
90+
91+
if (sdkVersionAsNumber >= 53) {
92+
return '';
93+
}
94+
95+
// Older SDK versions need the override keyword
96+
return 'override';
97+
}
8098
}
8199

82100
export function objCFileUpdater(originalContents: string): string {

0 commit comments

Comments
 (0)