Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compiling when using AppDelegate.mm #58

Open
fbotalla opened this issue Jan 5, 2023 · 8 comments
Open

Not compiling when using AppDelegate.mm #58

fbotalla opened this issue Jan 5, 2023 · 8 comments

Comments

@fbotalla
Copy link

fbotalla commented Jan 5, 2023

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?

@bradherman
Copy link

Also running into this issue

@bradherman
Copy link

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 ?

@fbotalla
Copy link
Author

fbotalla commented Mar 1, 2023

@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.

@HwangTaehyun
Copy link
Owner

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

@sofian-sunny
Copy link

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 _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)getModuleInstanceFromClass:(Class)moduleClass
    {
    return RCTAppSetupDefaultModuleFromClass(moduleClass);
    }

#endif

@EnD

@fbotalla
Copy link
Author

fbotalla commented Apr 4, 2023

@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
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants