// Copyright 2025-present 650 Industries. All rights reserved. #import #import #import #if __has_include() #import #else #import "ExpoModulesCore-Swift.h" #endif #import @implementation EXReactNativeFactory { EXAppContext *_appContext; } #pragma mark - RCTHostDelegate // [main thread] - (void)hostDidStart:(nonnull RCTHost *)host { // Setting the runtime delegate here doesn't feel right, but there is no other way // to capture the `host:didInitializeRuntime:` method call. // With the current API design we also depend that the runtime is initialized after the host started, // which isn't obvious, especially they are invoked on different threads. // Ideally if the current `RCTHostRuntimeDelegate` is part of `RCTHostDelegate`. host.runtimeDelegate = self; } #pragma mark - RCTHostRuntimeDelegate // [JS thread] - (void)host:(nonnull RCTHost *)host didInitializeRuntime:(jsi::Runtime &)runtime { _appContext = [[EXAppContext alloc] init]; // Inject and decorate the `global.expo` object _appContext._runtime = [[EXRuntime alloc] initWithRuntime:runtime]; [_appContext setHostWrapper:[[EXHostWrapper alloc] initWithHost:host]]; [_appContext registerNativeModules]; } @end