Skip to content

Commit

Permalink
[modules] Fix global.expo object installation on iOS (#19354)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsapeta committed Oct 3, 2022
1 parent beecb66 commit 98fa297
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/expo-modules-core/ios/JSI/EXJavaScriptRuntime.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ - (nonnull instancetype)init
_runtime = jsc::makeJSCRuntime();
#endif
_jsCallInvoker = nil;

// Add the main object to the runtime (`global.expo`).
_mainObject = [self createObject];
[[self global] defineProperty:mainObjectPropertyName value:_mainObject options:EXJavaScriptObjectPropertyDescriptorEnumerable];
[self initializeMainObject];
}
return self;
}
Expand All @@ -60,6 +57,7 @@ - (nonnull instancetype)initWithRuntime:(nonnull jsi::Runtime *)runtime
// See explanation for constructor (8): https://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr
_runtime = std::shared_ptr<jsi::Runtime>(std::shared_ptr<jsi::Runtime>(), runtime);
_jsCallInvoker = callInvoker;
[self initializeMainObject];
}
return self;
}
Expand Down Expand Up @@ -188,6 +186,15 @@ - (nonnull EXJavaScriptValue *)evaluateScript:(nonnull NSString *)scriptSource

#pragma mark - Private

- (void)initializeMainObject
{
if (!_mainObject) {
// Add the main object to the runtime (`global.expo`).
_mainObject = [self createObject];
[[self global] defineProperty:mainObjectPropertyName value:_mainObject options:EXJavaScriptObjectPropertyDescriptorEnumerable];
}
}

- (nonnull EXJavaScriptObject *)createHostFunction:(nonnull NSString *)name
argsCount:(NSInteger)argsCount
block:(nonnull JSHostFunctionBlock)block
Expand Down

0 comments on commit 98fa297

Please sign in to comment.