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

Not compiling when using AppDelegate.mm

Open fbotalla opened this issue 2 years ago • 8 comments

Issue is happening when changing the AppDelegate.m to AppDelegate.mm

It works fine with .m It does not compile with .mm with errors in the [project]-Swift file

Attempting to use the forward class 'INIntent' as superclass of 'ConfigurationIntent' && Attempting to use the forward class 'INIntentResponse' as superclass of 'ConfigurationIntentResponse'

Anyone else is having a similar issue?

fbotalla avatar Jan 05 '23 14:01 fbotalla

@fbotalla I don't know well about this issue. Could you try this one? https://stackoverflow.com/questions/63425027/attempting-to-use-the-forward-class-nsmanagedobjectmodel-as-superclass-of-swif#:~:text=You%20should%20set%20Enable%20modules(c%20and%20objective%20c)%20in%20build%20setting.%20Add%20%2Dfmodules%20in%20Other%20C%20Flags%2C%20add%20%2Dfcxx%2Dmodules%20in%20Other%20C%2B%2B%20Flags

https://stackoverflow.com/questions/57914899/module-swift-h-file-not-found-in-mm-file-in-building-unity-swift-framework

HwangTaehyun avatar Jan 23 '23 18:01 HwangTaehyun

Also running into this issue

bradherman avatar Feb 27 '23 22:02 bradherman

Issue is happening when changing the AppDelegate.m to AppDelegate.mm

It works fine with .m It does not compile with .mm with errors in the [project]-Swift file

Attempting to use the forward class 'INIntent' as superclass of 'ConfigurationIntent' && Attempting to use the forward class 'INIntentResponse' as superclass of 'ConfigurationIntentResponse'

Anyone else is having a similar issue?

did you find a fix @fbotalla ?

bradherman avatar Feb 28 '23 23:02 bradherman

@HwangTaehyun Sorry it took me so long to respond. I did try those fixes but still running into the same issue. @bradherman No, I haven't found a fix. I am currently using .mm without the lottie splash.

fbotalla avatar Mar 01 '23 00:03 fbotalla

@fbotalla I will find ways to resolve this within a few weeks. Sorry for being late.

HwangTaehyun avatar Mar 19 '23 05:03 HwangTaehyun

After some struggle i m able to compile AppDelegate.mm -- instead of AnimationView we have to use LottieAnimationView

AppDelegate.mm code

#import "AppDelegate.h"

#import <React/RCTBridge.h> #import <React/RCTBundleURLProvider.h> #import <React/RCTRootView.h>

// #import <GoogleMaps/GoogleMaps.h> #import <React/RCTAppSetupUtils.h> #import <Firebase.h> #import "RNSplashScreen.h" // here #import "Leeway-Swift.h" // here, change project name to yours //#import <GoogleMaps/GoogleMaps.h>

#if RCT_NEW_ARCH_ENABLED #import <React/CoreModulesPlugins.h> #import <React/RCTCxxBridgeDelegate.h> #import "React/RCTBridgeModule.h" #import <React/RCTFabricSurfaceHostingProxyRootView.h> #import <React/RCTSurfacePresenter.h> #import <React/RCTSurfacePresenterBridgeAdapter.h> #import <ReactCommon/RCTTurboModuleManager.h> #import <react/config/ReactNativeConfig.h>

static NSString *const kRNConcurrentRoot = @"concurrentRoot";

@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> { RCTTurboModuleManager *_turboModuleManager; RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig; facebook::react::ContextContainer::Shared _contextContainer; } @end #endif

@implementation AppDelegate

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    RCTAppSetupPrepareApp(application); RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; #if RCT_NEW_ARCH_ENABLED _contextContainer = std::make_shared<facebook::react::ContextContainer const>(); _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>(); _contextContainer->insert("ReactNativeConfig", _reactNativeConfig); _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer]; bridge.surfacePresenter = _bridgeAdapter.surfacePresenter; #endif

    NSDictionary *initProps = [self prepareInitialProps]; UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"Leeway", initProps);

    if (@available(iOS 13.0, *)) { rootView.backgroundColor = [UIColor systemBackgroundColor]; } else { rootView.backgroundColor = [UIColor whiteColor]; }

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIViewController *rootViewController = [UIViewController new];

    rootViewController.view = rootView;

    self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible];

    Dynamic *t = [Dynamic new]; UIView *animationUIView = (UIView *)[t createAnimationViewWithRootView:rootView lottieName:@"loading"]; // change lottieName to your lottie files name animationUIView.backgroundColor = [UIColor whiteColor]; // change backgroundColor

    // register LottieSplashScreen to RNSplashScreen [RNSplashScreen showLottieSplash:animationUIView inRootView:rootView];

    // casting UIView type to AnimationView type LottieAnimationView *animationView = (LottieAnimationView *) animationUIView; // play [t playWithAnimationView:animationView];

    // If you want the animation layout to be forced to remove when hide is called, use this code [RNSplashScreen setAnimationFinished:true];

    return YES; }

/// This method controls whether the concurrentRootfeature of React18 is turned on or off. /// /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). /// @return: true if the concurrentRoot feture is enabled. Otherwise, it returns false.

  • (BOOL)concurrentRootEnabled { // Switch this bool to turn on and off the concurrent root return true; }

  • (NSDictionary *)prepareInitialProps { NSMutableDictionary *initProps = [NSMutableDictionary new];

#ifdef RCT_NEW_ARCH_ENABLED initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]); #endif

return initProps; }

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

#if RCT_NEW_ARCH_ENABLED

#pragma mark - RCTCxxBridgeDelegate

  • (std::unique_ptrfacebook::react::JSExecutorFactory)jsExecutorFactoryForBridge:(RCTBridge *)bridge { _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge delegate:self jsInvoker:bridge.jsCallInvoker]; return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager); }

#pragma mark RCTTurboModuleManagerDelegate

  • (Class)getModuleClassFromName:(const char *)name { return RCTCoreModulesClassProvider(name); }

  • (std::shared_ptrfacebook::react::TurboModule)getTurboModule:(const std::string &)name jsInvoker:(std::shared_ptrfacebook::react::CallInvoker)jsInvoker { return nullptr; }

  • (std::shared_ptrfacebook::react::TurboModule)getTurboModule:(const std::string &)name initParams: (const facebook::react::ObjCTurboModule::InitParams &)params { return nullptr; }

  • (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass { return RCTAppSetupDefaultModuleFromClass(moduleClass); }

#endif

@end

sofian-sunny avatar Mar 30 '23 17:03 sofian-sunny

@sofian-sunny Thank you for helping out. I am getting this error

Unknown type name 'LottieAnimationView'; did you mean 'AnimationView'?

and also

Attempting to use the forward class 'INIntent' as superclass of 'ConfigurationIntent'

Did you do anything else on your end?

fbotalla avatar Apr 04 '23 22:04 fbotalla

@HwangTaehyun I don't want to rush or put pressure, just wanting to check in on the progress ?

Thank you for the awesome library btw.

fbotalla avatar Apr 26 '23 21:04 fbotalla