Closed Kudo closed 1 year ago
for app that don't use expo, is there any guide to integrate v8?
@aweffr sorry i didn't get a chance to update the readme. the necessary change should only be inside AppDelegate.mm
#ifndef FOLLY_NO_CONFIG
#define FOLLY_NO_CONFIG 1
#endif
#ifndef FOLLY_MOBILE
#define FOLLY_MOBILE 1
#endif
#ifndef FOLLY_USE_LIBCPP
#define FOLLY_USE_LIBCPP 1
#endif
#ifndef FOLLY_HAVE_PTHREAD
#define FOLLY_HAVE_PTHREAD 1
#endif
#import <memory>
#import <React/RCTCxxBridgeDelegate.h>
#import <React/RCTJSIExecutorRuntimeInstaller.h>
#import <RNV8/V8ExecutorFactory.h>
#if RCT_NEW_ARCH_ENABLED
#import <ReactCommon/RCTTurboModuleManager.h>
#endif
#if RCT_NEW_ARCH_ENABLED
@interface AppDelegate() <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate>
@end
#else
@interface AppDelegate() <RCTCxxBridgeDelegate>
@end
#endif // RCT_NEW_ARCH_ENABLED
jsExecutorFactoryForBridge:
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
#if RCT_NEW_ARCH_ENABLED
self.turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
delegate:self
jsInvoker:bridge.jsCallInvoker];
// Necessary to allow NativeModules to lookup TurboModules
[bridge setRCTTurboModuleRegistry:self.turboModuleManager];
#if RCT_DEV
if (!RCTTurboModuleEagerInitEnabled()) {
/**
* Instantiating DevMenu has the side-effect of registering
* shortcuts for CMD + d, CMD + i, and CMD + n via RCTDevMenu.
* Therefore, when TurboModules are enabled, we must manually create this
* NativeModule.
*/
[self.turboModuleManager moduleForName:"RCTDevMenu"];
}
#endif // RCT_DEV
return std::make_unique<rnv8::V8ExecutorFactory>(
facebook::react::RCTJSIExecutorRuntimeInstaller([bridge, turboModuleManager = self.turboModuleManager](facebook::jsi::Runtime &runtime) {
if (!bridge || !turboModuleManager) {
return;
}
facebook::react::RuntimeExecutor syncRuntimeExecutor =
[&](std::function<void(facebook::jsi::Runtime & runtime_)> &&callback) { callback(runtime); };
[turboModuleManager installJSBindingWithRuntimeExecutor:syncRuntimeExecutor];
}));
#else
return std::make_unique<rnv8::V8ExecutorFactory>(facebook::react::RCTJSIExecutorRuntimeInstaller(nullptr));
#endif // RCT_NEW_ARCH_ENABLED
}
Why
Since Xcode 14 has deprecated BitCode, it is a good time to revisit iOS support.
How
freeze_flags_after_init
v8 flagreact-native-template-v8
Test Plan