HwangTaehyun / react-native-lottie-splash-screen

⚡ Lottie splash screen for your react native app!
MIT License
222 stars 62 forks source link

Animation not showing on iOs #90

Closed AngelRmrz closed 7 months ago

AngelRmrz commented 8 months ago

The output of react-native info

System:
  OS: macOS 14.4
  CPU: (8) arm64 Apple M2
  Memory: 85.13 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.2
    path: ~/.nvm/versions/node/v18.18.2/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v18.18.2/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.nvm/versions/node/v18.18.2/bin/npm
  Watchman:
    version: 2023.10.09.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10811636
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.21
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.6
    wanted: 0.72.6
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Version of react-native-splash screen: ^1.1.2

Here is the AppDelegate code

#import "AppDelegate.h"

#import <React/RCTBundleURLProvider.h>
#import "RNSplashScreen.h"
#import "App-Swift.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.moduleName = @"App";
  // 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 success = [super application:application didFinishLaunchingWithOptions:launchOptions];

  if (success) {
     UIView *rootView = self.window.rootViewController.view;

     rootView.backgroundColor = [UIColor whiteColor];

     Dynamic *t = [Dynamic new];
     UIView *animationUIView = (UIView *)[t createAnimationViewWithRootView:rootView lottieName:@"splash_screen"];
       [RNSplashScreen showLottieSplash:animationUIView inRootView:rootView];
     LottieAnimationView *animationView = (LottieAnimationView *) animationUIView;
     [t playWithAnimationView:animationView];
    [RNSplashScreen setAnimationFinished:true];
   }
  return success;
}

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

@end

Here is the Dynamic.swift archive

import UIKit
import Foundation
import Lottie

@objc class Dynamic: NSObject {

  @objc func createAnimationView(rootView: UIView, lottieName: String) -> LottieAnimationView {
    let animationView = LottieAnimationView(name: lottieName)
    animationView.frame = rootView.frame
    animationView.center = rootView.center
    animationView.backgroundColor = UIColor.white;
    return animationView;
  }

  @objc func play(animationView: LottieAnimationView) {
    animationView.play(
      completion: { (success) in
        RNSplashScreen.setAnimationFinished(true)
      }
    );
  }
}

I can't provide more reproducible code because, it works on android, but on iOs, keeps throwing the default splash screen.

https://github.com/HwangTaehyun/react-native-lottie-splash-screen/assets/69778769/877ec0a1-d1b5-46f0-9566-cff9531984da

AshishVermaSimply commented 7 months ago

In AppDeligate.m file comment the line: // self.initialProps = @{};

iOznny commented 7 months ago

Hola Angel.

Una duda, tu archivo "splash_screen", ¿en donde lo ubicaste o colocaste dentro del proyecto para que tu AppDelegate lo identifique?

¿Ya lograste correr Lottie en iOS?

Saludos.

AngelRmrz commented 7 months ago

Still with no response, maybe the animation layer on ios is not reading the lottie file.