Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion plugin/src/withRNOrientationAppDelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand All @@ -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 {
Expand Down
Loading