SDK41 expo-splash-screen patch failing on iOS

Hey there,

back in SDK40 I patched expo-splash-screen to hide the app’s content from the AppSwitcher when the app goes to background. This worked fine until I upgraded to SDK41. Now I’m getting the following error:

NSInvalidArgumentException (RNSScreen)
-[EXSplashScreenService forceShowSplashScreenFor:]: unrecognized selector sent to instance 0x600000d24310

The error is thrown in applicationDidEnterBackground, it doesn’t even enter the forceShowSplashScreenFor function. I’m not an iOS developer - any idea what I’m missing here?

diff --git a/ios/MyApp/AppDelegate.m b/ios/MyApp/AppDelegate.m
index 5a081f14..c5662908 100644
--- a/ios/MyApp/AppDelegate.m
+++ b/ios/MyApp/AppDelegate.m
@@ -96,7 +96,7 @@ - (RCTBridge *)initializeReactNativeApp
   rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

   self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
-  UIViewController *rootViewController = [[EXScreenOrientationViewController alloc]
+  UIViewController *rootViewController = [[EXScreenOrientationViewController alloc]
   initWithDefaultScreenOrientationMask:UIInterfaceOrientationMaskPortrait];
   rootViewController.view = rootView;
   self.window.rootViewController = rootViewController;
@@ -126,4 +126,16 @@ - (void)appController:(EXUpdatesAppController *)appController didStartWithSucces
   [splashScreenService showSplashScreenFor:self.window.rootViewController];
 }

+- (void)applicationWillEnterForeground:(UIApplication *)application {
+  EXSplashScreenService *splashScreenService = (EXSplashScreenService *)[UMModuleRegistryProvider getSingletonModuleForClass:[EXSplashScreenService class]];
+  [splashScreenService hideSplashScreenFor:self.window.rootViewController
+                       successCallback:^(BOOL hasEffect){ /* IGNORE */ }
+                       failureCallback:^(NSString *message){ /* IGNORE */ }];
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+  EXSplashScreenService *splashScreenService = (EXSplashScreenService *)[UMModuleRegistryProvider getSingletonModuleForClass:[EXSplashScreenService class]];
+  [splashScreenService forceShowSplashScreenFor:self.window.rootViewController];
+}
+
 @end

and the patch for expo-splash-screen to add the forceShowSplashScreenFor function:

diff --git a/node_modules/expo-splash-screen/ios/EXSplashScreen/EXSplashScreenService.h b/node_modules/expo-splash-screen/ios/EXSplashScreen/EXSplashScreenService.h
index d4e6372..8555c0a 100644
--- a/node_modules/expo-splash-screen/ios/EXSplashScreen/EXSplashScreenService.h
+++ b/node_modules/expo-splash-screen/ios/EXSplashScreen/EXSplashScreenService.h
@@ -15,6 +15,12 @@ NS_ASSUME_NONNULL_BEGIN
 */
 @protocol EXSplashScreenService <NSObject>
 
+/**
+ * patched method to force re-showing of the splash screen
+ */
+- (void)forceShowSplashScreenFor:(UIViewController *)viewController;
+
+
 /**
  * Overloaded method. See main method below.
  */
diff --git a/node_modules/expo-splash-screen/ios/EXSplashScreen/EXSplashScreenService.m b/node_modules/expo-splash-screen/ios/EXSplashScreen/EXSplashScreenService.m
index 72ababa..c56a888 100644
--- a/node_modules/expo-splash-screen/ios/EXSplashScreen/EXSplashScreenService.m
+++ b/node_modules/expo-splash-screen/ios/EXSplashScreen/EXSplashScreenService.m
@@ -22,6 +22,12 @@ - (instancetype)init
   return self;
 }
 
+- (void)forceShowSplashScreenFor:(UIViewController *)viewController
+{
+  return [[self.splashScreenControllers objectForKey:viewController] showWithCallback:^{}
+                                                                      failureCallback:^(NSString *message){ UMLogWarn(@"%@", message); }];
+}
+
 - (void)showSplashScreenFor:(UIViewController *)viewController
 {
   id<EXSplashScreenViewProvider> splashScreenViewProvider = [EXSplashScreenViewNativeProvider new];

The prebuilt binary introduced in SDK41 was the problem. opting out of pre-build solved my problem:

diff --git a/node_modules/expo-splash-screen/ios/EXSplashScreen.podspec b/node_modules/expo-splash-screen/ios/EXSplashScreen.podspec
index 084325b..0c3009b 100644
--- a/node_modules/expo-splash-screen/ios/EXSplashScreen.podspec
+++ b/node_modules/expo-splash-screen/ios/EXSplashScreen.podspec
@@ -16,10 +16,6 @@ Pod::Spec.new do |s|
   s.dependency 'UMCore'
   s.dependency 'React-Core'

-  if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
-    s.source_files = "#{s.name}/**/*.h"
-    s.vendored_frameworks = "#{s.name}.xcframework"
-  else
-    s.source_files = "#{s.name}/**/*.{h,m}"
-  end
+  # compile ourselves because we're patching this module
+  s.source_files = "#{s.name}/**/*.{h,m}"
 end