From 8450abda5c7dc26229a27d180fcaba2099118832 Mon Sep 17 00:00:00 2001 From: Arnaud Roland Date: Thu, 20 Jun 2024 10:49:59 +0200 Subject: [PATCH] expo: fix rnbatch import during pre-build --- CHANGELOG.md | 7 +++++++ plugin/src/fixtures/appDelegate.ts | 2 ++ plugin/src/ios/withReactNativeBatchAppDelegate.ts | 3 +++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73cd341..7bef26c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +9.0.1 +---- + +**Expo** + +* Fixed an issue on iOS where the `RNBatch` import was not added during the Expo pre-build. + 9.0.0 ---- diff --git a/plugin/src/fixtures/appDelegate.ts b/plugin/src/fixtures/appDelegate.ts index 69daf7a..f7b1a68 100644 --- a/plugin/src/fixtures/appDelegate.ts +++ b/plugin/src/fixtures/appDelegate.ts @@ -157,6 +157,8 @@ static void InitializeFlipper(UIApplication *application) { export const appDelegateExpectedFixture = `#import "AppDelegate.h" +#import + #if defined(EX_DEV_MENU_ENABLED) @import EXDevMenu; #endif diff --git a/plugin/src/ios/withReactNativeBatchAppDelegate.ts b/plugin/src/ios/withReactNativeBatchAppDelegate.ts index f49cab2..8fe369d 100644 --- a/plugin/src/ios/withReactNativeBatchAppDelegate.ts +++ b/plugin/src/ios/withReactNativeBatchAppDelegate.ts @@ -3,9 +3,12 @@ import { ConfigPlugin, withAppDelegate } from '@expo/config-plugins'; const DID_FINISH_LAUNCHING_WITH_OPTIONS_DECLARATION = '- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{'; +const IMPORT_BATCH = '\n\n#import \n'; const REGISTER_BATCH = '\n [RNBatch start];\n'; export const modifyAppDelegate = (contents: string) => { + contents = contents.replace('\n', IMPORT_BATCH); + const [beforeDeclaration, afterDeclaration] = contents.split(DID_FINISH_LAUNCHING_WITH_OPTIONS_DECLARATION); const newAfterDeclaration = DID_FINISH_LAUNCHING_WITH_OPTIONS_DECLARATION.concat(REGISTER_BATCH).concat(afterDeclaration);