From a2844a4f54c5a6f5b426de02d8e1d78c033f70c4 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Fri, 24 Oct 2025 23:33:19 +0200 Subject: [PATCH 1/3] fix: broken swiftFileUpdater --- .../withRNOrientationAppDelegate.spec.ts.snap | 93 +++++++++++++++++-- .../withRNOrientationAppDelegate.spec.ts | 19 +++- plugin/src/withRNOrientationAppDelegate.ts | 14 ++- 3 files changed, 111 insertions(+), 15 deletions(-) diff --git a/plugin/__tests__/__snapshots__/withRNOrientationAppDelegate.spec.ts.snap b/plugin/__tests__/__snapshots__/withRNOrientationAppDelegate.spec.ts.snap index 5dd10bb..e4846e5 100644 --- a/plugin/__tests__/__snapshots__/withRNOrientationAppDelegate.spec.ts.snap +++ b/plugin/__tests__/__snapshots__/withRNOrientationAppDelegate.spec.ts.snap @@ -77,7 +77,7 @@ exports[`withRNOrientationAppDelegate updates the AppDelegate.mm with both heade " `; -exports[`withRNOrientationAppDelegate updates the AppDelegate52.swift with the method implementation having override when sdk is < 53 1`] = ` +exports[`withRNOrientationAppDelegate updates the AppDelegate52.swift with the method implementation having public override when sdk is < 53 1`] = ` "import UIKit import React import React_RCTAppDelegate @@ -95,9 +95,9 @@ class AppDelegate: RCTAppDelegate { return super.application(application, didFinishLaunchingWithOptions: launchOptions) } -// React Native Orientation Director @generated begin @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation - expo prebuild (DO NOT MODIFY) sync-d346ef386403083e8a91af1cd77a5a77312aacfb +// React Native Orientation Director @generated begin @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation - expo prebuild (DO NOT MODIFY) sync-e6869f486930a8ef16098c6ceec0011ee7ff621f - override func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { + func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return OrientationDirector.getSupportedInterfaceOrientationsForWindow() } @@ -118,7 +118,7 @@ class AppDelegate: RCTAppDelegate { " `; -exports[`withRNOrientationAppDelegate updates the AppDelegate53.swift with the method implementation without override when sdk is >= 53 1`] = ` +exports[`withRNOrientationAppDelegate updates the AppDelegate53.swift with the method implementation without override when sdk is greater than or equal to 53 1`] = ` "import Expo import React import ReactAppDependencyProvider @@ -152,9 +152,90 @@ public class AppDelegate: ExpoAppDelegate { return super.application(application, didFinishLaunchingWithOptions: launchOptions) } -// React Native Orientation Director @generated begin @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation - expo prebuild (DO NOT MODIFY) sync-e6869f486930a8ef16098c6ceec0011ee7ff621f +// React Native Orientation Director @generated begin @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation - expo prebuild (DO NOT MODIFY) sync-147d50248b7b55d1acbe02fc03ff4cde90a30975 - func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { + public override func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { + return OrientationDirector.getSupportedInterfaceOrientationsForWindow() + } + +// React Native Orientation Director @generated end @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation + + // Linking API + public override func application( + _ app: UIApplication, + open url: URL, + options: [UIApplication.OpenURLOptionsKey: Any] = [:] + ) -> Bool { + return super.application(app, open: url, options: options) || RCTLinkingManager.application(app, open: url, options: options) + } + + // Universal Links + public override func application( + _ application: UIApplication, + continue userActivity: NSUserActivity, + restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void + ) -> Bool { + let result = RCTLinkingManager.application(application, continue: userActivity, restorationHandler: restorationHandler) + return super.application(application, continue: userActivity, restorationHandler: restorationHandler) || result + } +} + +class ReactNativeDelegate: ExpoReactNativeFactoryDelegate { + // Extension point for config-plugins + + override func sourceURL(for bridge: RCTBridge) -> URL? { + // needed to return the correct URL for expo-dev-client. + bridge.bundleURL ?? bundleURL() + } + + override func bundleURL() -> URL? { +#if DEBUG + return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: ".expo/.virtual-metro-entry") +#else + return Bundle.main.url(forResource: "main", withExtension: "jsbundle") +#endif + } +} +" +`; + +exports[`withRNOrientationAppDelegate updates the AppDelegate53.swift with the method implementation without override when sdk is greater than or equal to 54 1`] = ` +"import Expo +import React +import ReactAppDependencyProvider + +@UIApplicationMain +public class AppDelegate: ExpoAppDelegate { + var window: UIWindow? + + var reactNativeDelegate: ExpoReactNativeFactoryDelegate? + var reactNativeFactory: RCTReactNativeFactory? + + public override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil + ) -> Bool { + let delegate = ReactNativeDelegate() + let factory = ExpoReactNativeFactory(delegate: delegate) + delegate.dependencyProvider = RCTAppDependencyProvider() + + reactNativeDelegate = delegate + reactNativeFactory = factory + bindReactNativeFactory(factory) + +#if os(iOS) || os(tvOS) + window = UIWindow(frame: UIScreen.main.bounds) + factory.startReactNative( + withModuleName: "main", + in: window, + launchOptions: launchOptions) +#endif + + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +// React Native Orientation Director @generated begin @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation - expo prebuild (DO NOT MODIFY) sync-147d50248b7b55d1acbe02fc03ff4cde90a30975 + + public override func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return OrientationDirector.getSupportedInterfaceOrientationsForWindow() } diff --git a/plugin/__tests__/withRNOrientationAppDelegate.spec.ts b/plugin/__tests__/withRNOrientationAppDelegate.spec.ts index 6da7db6..1e718bc 100644 --- a/plugin/__tests__/withRNOrientationAppDelegate.spec.ts +++ b/plugin/__tests__/withRNOrientationAppDelegate.spec.ts @@ -19,25 +19,36 @@ describe('withRNOrientationAppDelegate', function () { expect(result).toMatchSnapshot(); }); - it('updates the AppDelegate52.swift with the method implementation having override when sdk is < 53', async function () { + it('updates the AppDelegate52.swift with the method implementation having public override when sdk is < 53', async function () { const appDelegatePath = path.join( __dirname, './fixtures/AppDelegate52.swift' ); const appDelegate = await fs.promises.readFile(appDelegatePath, 'utf-8'); - const result = swiftFileUpdater(appDelegate, '52'); + const result = swiftFileUpdater(appDelegate, '52.0.0'); expect(result).toMatchSnapshot(); }); - it('updates the AppDelegate53.swift with the method implementation without override when sdk is >= 53', async function () { + it('updates the AppDelegate53.swift with the method implementation without override when sdk is greater than or equal to 53', async function () { const appDelegatePath = path.join( __dirname, './fixtures/AppDelegate53.swift' ); const appDelegate = await fs.promises.readFile(appDelegatePath, 'utf-8'); - const result = swiftFileUpdater(appDelegate, '53'); + const result = swiftFileUpdater(appDelegate, '53.0.0'); + expect(result).toMatchSnapshot(); + }); + + it('updates the AppDelegate53.swift with the method implementation without override when sdk is greater than or equal to 54', async function () { + const appDelegatePath = path.join( + __dirname, + './fixtures/AppDelegate53.swift' + ); + const appDelegate = await fs.promises.readFile(appDelegatePath, 'utf-8'); + + const result = swiftFileUpdater(appDelegate, '54.0.0'); expect(result).toMatchSnapshot(); }); }); diff --git a/plugin/src/withRNOrientationAppDelegate.ts b/plugin/src/withRNOrientationAppDelegate.ts index ddbcd90..41cf8a0 100644 --- a/plugin/src/withRNOrientationAppDelegate.ts +++ b/plugin/src/withRNOrientationAppDelegate.ts @@ -83,17 +83,21 @@ export function swiftFileUpdater( return ''; } - const sdkVersionAsNumber = Number(_sdkVersion); - if (Number.isNaN(sdkVersionAsNumber)) { + const rawMajor = _sdkVersion.split('.').at(0); + if (!rawMajor) { return ''; } - if (sdkVersionAsNumber >= 53) { + const major = Number(rawMajor); + if (Number.isNaN(major)) { return ''; } - // Older SDK versions need the override keyword - return 'override'; + if (major >= 53) { + return 'public override'; + } + + return ''; } } From 24bfd7a775e867411fcf4e84c310c5fd878acf68 Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Fri, 24 Oct 2025 23:48:27 +0200 Subject: [PATCH 2/3] fix: broken swiftFileUpdater --- plugin/__tests__/withRNOrientationAppDelegate.spec.ts | 6 +++--- plugin/src/withRNOrientationAppDelegate.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin/__tests__/withRNOrientationAppDelegate.spec.ts b/plugin/__tests__/withRNOrientationAppDelegate.spec.ts index 1e718bc..4e6a657 100644 --- a/plugin/__tests__/withRNOrientationAppDelegate.spec.ts +++ b/plugin/__tests__/withRNOrientationAppDelegate.spec.ts @@ -19,7 +19,7 @@ describe('withRNOrientationAppDelegate', function () { expect(result).toMatchSnapshot(); }); - it('updates the AppDelegate52.swift with the method implementation having public override when sdk is < 53', async function () { + it('updates the AppDelegate52.swift with the method implementation having public override when sdk is <= 52', async function () { const appDelegatePath = path.join( __dirname, './fixtures/AppDelegate52.swift' @@ -30,7 +30,7 @@ describe('withRNOrientationAppDelegate', function () { expect(result).toMatchSnapshot(); }); - it('updates the AppDelegate53.swift with the method implementation without override when sdk is greater than or equal to 53', async function () { + it('updates the AppDelegate53.swift with the method implementation without public override when sdk is equal to 53', async function () { const appDelegatePath = path.join( __dirname, './fixtures/AppDelegate53.swift' @@ -41,7 +41,7 @@ describe('withRNOrientationAppDelegate', function () { expect(result).toMatchSnapshot(); }); - it('updates the AppDelegate53.swift with the method implementation without override when sdk is greater than or equal to 54', async function () { + it('updates the AppDelegate53.swift with the method implementation having public override when sdk is greater than or equal to 54', async function () { const appDelegatePath = path.join( __dirname, './fixtures/AppDelegate53.swift' diff --git a/plugin/src/withRNOrientationAppDelegate.ts b/plugin/src/withRNOrientationAppDelegate.ts index 41cf8a0..d1207ee 100644 --- a/plugin/src/withRNOrientationAppDelegate.ts +++ b/plugin/src/withRNOrientationAppDelegate.ts @@ -93,11 +93,11 @@ export function swiftFileUpdater( return ''; } - if (major >= 53) { - return 'public override'; + if (major === 53) { + return ''; } - return ''; + return 'public override'; } } From 4247375c4de54f36b98d7d7ca303b8db1ca3098a Mon Sep 17 00:00:00 2001 From: gladiuscode Date: Fri, 24 Oct 2025 23:49:35 +0200 Subject: [PATCH 3/3] chore: update snapshot --- .../withRNOrientationAppDelegate.spec.ts.snap | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugin/__tests__/__snapshots__/withRNOrientationAppDelegate.spec.ts.snap b/plugin/__tests__/__snapshots__/withRNOrientationAppDelegate.spec.ts.snap index e4846e5..ccc4a04 100644 --- a/plugin/__tests__/__snapshots__/withRNOrientationAppDelegate.spec.ts.snap +++ b/plugin/__tests__/__snapshots__/withRNOrientationAppDelegate.spec.ts.snap @@ -77,7 +77,7 @@ exports[`withRNOrientationAppDelegate updates the AppDelegate.mm with both heade " `; -exports[`withRNOrientationAppDelegate updates the AppDelegate52.swift with the method implementation having public override when sdk is < 53 1`] = ` +exports[`withRNOrientationAppDelegate updates the AppDelegate52.swift with the method implementation having public override when sdk is <= 52 1`] = ` "import UIKit import React import React_RCTAppDelegate @@ -95,9 +95,9 @@ class AppDelegate: RCTAppDelegate { return super.application(application, didFinishLaunchingWithOptions: launchOptions) } -// React Native Orientation Director @generated begin @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation - expo prebuild (DO NOT MODIFY) sync-e6869f486930a8ef16098c6ceec0011ee7ff621f +// React Native Orientation Director @generated begin @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation - expo prebuild (DO NOT MODIFY) sync-147d50248b7b55d1acbe02fc03ff4cde90a30975 - func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { + public override func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return OrientationDirector.getSupportedInterfaceOrientationsForWindow() } @@ -118,7 +118,7 @@ class AppDelegate: RCTAppDelegate { " `; -exports[`withRNOrientationAppDelegate updates the AppDelegate53.swift with the method implementation without override when sdk is greater than or equal to 53 1`] = ` +exports[`withRNOrientationAppDelegate updates the AppDelegate53.swift with the method implementation having public override when sdk is greater than or equal to 54 1`] = ` "import Expo import React import ReactAppDependencyProvider @@ -199,7 +199,7 @@ class ReactNativeDelegate: ExpoReactNativeFactoryDelegate { " `; -exports[`withRNOrientationAppDelegate updates the AppDelegate53.swift with the method implementation without override when sdk is greater than or equal to 54 1`] = ` +exports[`withRNOrientationAppDelegate updates the AppDelegate53.swift with the method implementation without public override when sdk is equal to 53 1`] = ` "import Expo import React import ReactAppDependencyProvider @@ -233,9 +233,9 @@ public class AppDelegate: ExpoAppDelegate { return super.application(application, didFinishLaunchingWithOptions: launchOptions) } -// React Native Orientation Director @generated begin @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation - expo prebuild (DO NOT MODIFY) sync-147d50248b7b55d1acbe02fc03ff4cde90a30975 +// React Native Orientation Director @generated begin @react-native-orientation-director/supportedInterfaceOrientationsFor-implementation - expo prebuild (DO NOT MODIFY) sync-e6869f486930a8ef16098c6ceec0011ee7ff621f - public override func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { + func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { return OrientationDirector.getSupportedInterfaceOrientationsForWindow() }