Skip to content

Commit

Permalink
[ios] Enable TurboModules based on a flag (#9908)
Browse files Browse the repository at this point in the history
# Why

With TurboModules enabled, remote debugging must be disabled. As remote debugging is a must-have feature we want to be able to enable/disable TurboModules at will.

I will also add a PR to `universe` for XDL schema. The name was inspired by Android's `enableDangerousExperimentalLeanBuilds`.

# How

It looks like `configureWithABI` is called once for every bridge reload, so enabling/disabling TurboModules in there *should* be enough.

# Test Plan

I have verified that:
- Home with TM disabled works
- running NCL with TM enabled works
- going back to Home with TM disabled works
- refreshing NCL with TM setting toggled and dev server restarted works
  • Loading branch information
sjchmiela committed Aug 25, 2020
1 parent c6134b4 commit fd13d3a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,8 @@ Package-specific changes not released in any SDK will be added here just before

### 🎉 New features

- Added support for `experiments.turboModules` flag in `app.json`/`app.config.js` allowing developers to enable Turbo Modules on iOS. ([#9908](https://github.com/expo/expo/pull/9908) by [@sjchmiela](https://github.com/sjchmiela))

### 🐛 Bug fixes

## 39.0.0 — 2020-08-18
Expand Down
13 changes: 12 additions & 1 deletion ios/Exponent/Versioned/Core/EXVersionManager.mm
Expand Up @@ -263,7 +263,7 @@ - (void)configureABIWithFatalHandler:(void (^)(NSError *))fatalHandler
logFunction:(RCTLogFunction)logFunction
logThreshold:(NSInteger)threshold
{
RCTEnableTurboModule(YES);
RCTEnableTurboModule([self.params[@"manifest"][@"experiments"][@"turboModules"] boolValue]);
RCTSetFatalHandler(fatalHandler);
RCTSetLogThreshold((RCTLogLevel) threshold);
RCTSetLogFunction(logFunction);
Expand Down Expand Up @@ -316,6 +316,17 @@ - (NSArray *)extraModulesForBridge:(id)bridge
UMModuleRegistry *moduleRegistry = [moduleRegistryAdapter moduleRegistryForParams:params forExperienceId:experienceId withKernelServices:services];
NSArray<id<RCTBridgeModule>> *expoModules = [moduleRegistryAdapter extraModulesForModuleRegistry:moduleRegistry];
[extraModules addObjectsFromArray:expoModules];

if (!RCTTurboModuleEnabled()) {
[extraModules addObject:[self getModuleInstanceFromClass:[self getModuleClassFromName:"DevSettings"]]];
id exceptionsManager = [self getModuleInstanceFromClass:RCTExceptionsManagerCls()];
if (exceptionsManager) {
[extraModules addObject:exceptionsManager];
}
[extraModules addObject:[self getModuleInstanceFromClass:[self getModuleClassFromName:"DevMenu"]]];
[extraModules addObject:[self getModuleInstanceFromClass:[self getModuleClassFromName:"RedBox"]]];
[extraModules addObject:[self getModuleInstanceFromClass:RCTAsyncLocalStorageCls()]];
}

return extraModules;
}
Expand Down

0 comments on commit fd13d3a

Please sign in to comment.