react-native-quickjs icon indicating copy to clipboard operation
react-native-quickjs copied to clipboard

Old Architecture Support

Open gtokman opened this issue 1 year ago • 4 comments

I saw your example code and it looked like you were using the new architecture:

+  auto cacheDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject UTF8String];
+  return std::make_unique<qjs::QuickJSExecutorFactory>(installBindings, ""); // pass empty string to disable code cache
+#endif

Could you use this project with the old architecture?

gtokman avatar Jan 27 '24 20:01 gtokman

Which RN version are you working on? @gtokman

bojie-liu avatar Mar 10 '24 14:03 bojie-liu

Which RN version are you working on? @gtokman

I'm on the latest, 0.73.5 I believe.

gtokman avatar Mar 13 '24 11:03 gtokman

I've tried RCT_NEW_ARCH_ENABLED=0 pod install and it worked. What are the steps to reproduce your problem here?

bojie-liu avatar Apr 07 '24 01:04 bojie-liu

My code for setting up the JS bundle looks similar to the example app.

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

I saw you have a function that you overrode & it looks like this is where you specify QuickJS.

@implementation AppDelegate

- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
  auto installBindings = facebook::react::RCTJSIExecutorRuntimeInstaller(nullptr);
  auto cacheDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject UTF8String];
  return std::make_unique<qjs::QuickJSExecutorFactory>(installBindings, "");
}

My problems are:

  1. I'm using a new version of React Native
  2. My AppDelegate is in Swift & I couldn't get this project to compile after adding it as a dependency in Xcode

For example, this example app. Have you had luck installing this on a more modern project?

gtokman avatar Apr 20 '24 12:04 gtokman