Skip to content

Commit a2dfbdd

Browse files
authored
Merge pull request #261 from jpudysz/feature/init
feat: await initial values while initializing ios core
2 parents 441d799 + c8e3466 commit a2dfbdd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ios/platform/Platform_iOS.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ - (void)makeShared:(void*)runtime {
8181
return [self setRootViewBackgroundColor:color alpha:alpha];
8282
});
8383

84+
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
8485
dispatch_async(dispatch_get_main_queue(), ^{
8586
Screen screen = [self getScreenDimensions];
8687

@@ -92,7 +93,11 @@ - (void)makeShared:(void*)runtime {
9293
unistylesRuntime->pixelRatio = screen.pixelRatio;
9394
unistylesRuntime->fontScale = screen.fontScale;
9495
unistylesRuntime->rtl = [self isRtl];
96+
97+
dispatch_semaphore_signal(semaphore);
9598
});
99+
100+
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
96101
}
97102

98103
- (void)onAppearanceChange:(NSNotification *)notification {
@@ -155,7 +160,7 @@ - (bool)isRtl {
155160
BOOL hasForcedRtl = [[NSUserDefaults standardUserDefaults] boolForKey:@"RCTI18nUtil_forceRTL"];
156161
// user preferences
157162
BOOL isRtl = [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
158-
163+
159164
return hasForcedRtl || isRtl;
160165
}
161166

0 commit comments

Comments
 (0)