react-native-splash-screen icon indicating copy to clipboard operation
react-native-splash-screen copied to clipboard

Changes in AppDelegate from Objective-C to Swift in React Native 0.77 and Above

Open kasumil opened this issue 10 months ago β€’ 11 comments

Since React Native version 0.77, the AppDelegate has been changed from Objective-C to Swift for iOS projects. This means that your import statements and setup might need to be adjusted accordingly.

Can you tell me when these changes will be applied?

kasumil avatar Feb 21 '25 19:02 kasumil

πŸš€ Consider Using react-native-splash-view Instead!

Hey there! πŸ‘‹ If you're facing issues with AppDelegate changes in React Native 0.76+, you might want to try [react-native-splash-view] instead!

βœ… Why switch to react-native-splash-view?

  • Fully compatible with React Native 0.76+, including Swift-based AppDelegate.
  • No extra hassleβ€”works smoothly with both Objective-C & Swift projects.
  • Simple integration with iOS storyboard splash screens & Android launch screens.
  • Lightweight & actively maintained for the latest React Native versions.

Check it out & give it a try! πŸš€βœ¨

jagnesh avatar Feb 23 '25 08:02 jagnesh

πŸš€ Consider Using react-native-splash-view Instead!

Hey there! πŸ‘‹ If you're facing issues with AppDelegate changes in React Native 0.76+, you might want to try [react-native-splash-view] instead!

βœ… Why switch to react-native-splash-view?

  • Fully compatible with React Native 0.76+, including Swift-based AppDelegate.
  • No extra hassleβ€”works smoothly with both Objective-C & Swift projects.
  • Simple integration with iOS storyboard splash screens & Android launch screens.
  • Lightweight & actively maintained for the latest React Native versions.

Check it out & give it a try! πŸš€βœ¨

how to use in old AppDelegate instead swift?

muammadibal avatar Feb 24 '25 07:02 muammadibal

@muammadibal

please check readme for steps:

https://github.com/jagnesh/react-native-splash-view?tab=readme-ov-file#if-you-are-using-obj-c-update-appdelegatem-or-appdelegatemm

jagnesh avatar Feb 24 '25 12:02 jagnesh

umm...I was in a hurry, so I used react-native-bootsplash.

kasumil avatar Feb 24 '25 13:02 kasumil

umm...I was in a hurry, so I used react-native-bootsplash.

No worries! React Native Bootsplash is also a solid choice. 😊 However, for future projects, I’d recommend checking out react-native-splash-view. It supports React Native 0.76+ with the new architecture, works seamlessly with both iOS & Android, and allows more flexibility in controlling the splash screen from native & JS sides. πŸš€ Give it a look for your next project! πŸŽ‰

jagnesh avatar Feb 24 '25 13:02 jagnesh

Edit: This Objective-C workaround was created as a temporary solution I used to quickly publish an app in production. However, it's not the recommended approach since React Native is moving toward Swift, and we'll soon be migrating from CocoaPods to SPM. The better long-term solution is Swift migration with bridging header.


πŸ“‹ Objective-C Workaround (Click to expand)

Found a way to work around the AppDelegate.swift changes in React Native 0.77 and above.

As mentioned in the React Native 0.77 blog:

"New projects will be generated by using Swift as the iOS app language, although you can always migrate back to Objective-C if you need to."

Since react-native-splash-screen doesn't support Swift currently, migrating back to Objective-C is an option for compatibility.

Steps (using Xcode):

  1. Delete AppDelegate.swift.
  2. Recreate (refer to Upgrade Helper):
    • AppDelegate.h
    • main.m
    • AppDelegate.mm (Also, need to integrate RCTAppDependencyProvider which is a new change required in 0.77)

Updated AppDelegate.mm

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import <ReactAppDependencyProvider/RCTAppDependencyProvider.h>
#import "RNSplashScreen.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"RnDiffApp";
  self.dependencyProvider = [RCTAppDependencyProvider new];
  // You can add your custom initial props in the dictionary below.
  // They will be passed down to the ViewController used by React Native.
  self.initialProps = @{};

  bool didLaunchFinish = [super application:application didFinishLaunchingWithOptions:launchOptions];

  [RNSplashScreen show];
  
  return didLaunchFinish;
}

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
  return [self bundleURL];
}

- (NSURL *)bundleURL
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

@end

Note: Use Xcode to delete/recreate files so that project.pbxproj updates correctly. πŸš€

⚠️: Not recommended. This is a temporary workaround that goes against React Native's Swift direction and upcoming SPM migration. Use Swift with bridging headers instead for future compatibility.

sandipshiwakoti avatar Feb 24 '25 18:02 sandipshiwakoti

What worked for me was using a bridging header while doing the migration to Swift. You can check it out here.

jesusej avatar Mar 24 '25 20:03 jesusej

What worked for me was using a bridging header while doing the migration to Swift. You can check it out here.

Thanks for the tip! Would you mind sharing how you did it exactly? That would really help a lot. πŸ™

corderov avatar Apr 16 '25 17:04 corderov

change:AppDelegate.swift

override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { self.moduleName = "beidou_aiot" self.dependencyProvider = RCTAppDependencyProvider()

// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = [:]

let didLaunchFinish = super.application(application, didFinishLaunchingWithOptions: launchOptions)

let rnSplashScreenHelper = RNSplashScreenHelper()
rnSplashScreenHelper.show()

return didLaunchFinish

}

add:RNSplashScreenHelper.h

#ifndef RNSplashScreenHelper_h #define RNSplashScreenHelper_h

#import <Foundation/Foundation.h>

@interface RNSplashScreenHelper : NSObject

  • (void) show;

@end

#endif /* RNSplashScreenHelper_h */

add:RNSplashScreenHelper.m

#import "RNSplashScreenHelper.h" #import "RNSplashScreen.h" @implementation RNSplashScreenHelper

  • (void) show { [RNSplashScreen show]; }

@end

add your project name-Bridging-Header.h

#import "RNSplashScreenHelper.h"

jvssoft avatar Apr 24 '25 09:04 jvssoft

I got issue splash screen stuck forever ios

vorn-dev-ni avatar Jul 31 '25 07:07 vorn-dev-ni

To set up react-native-splash-screen on iOS:

Install the package:

  npm install react-native-splash-screen --save
  cd ios && pod install

In AppDelegate.swift, add:

    func application(
      _ application: UIApplication,
      didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
    ) -> Bool {
        // your existing code...
    
        RNSplashScreen.show()  // Show splash screen
    
        return true
    }

Create (or edit) the bridging header file: abcproject-Bridging-Header.h

#import "RNSplashScreen.h"

If the bridging header doesn’t exist, create it and then go to: Xcode β†’ Build Settings β†’ Swift Compiler - General β†’ Objective-C Bridging Header and set its path (e.g. $(PROJECT_NAME)/$(PROJECT_NAME)-Bridging-Header.h).

memanoj avatar Aug 26 '25 07:08 memanoj