From c8e3466d32983642f9603470b29687a46a47f122 Mon Sep 17 00:00:00 2001 From: Jacek Pudysz Date: Wed, 31 Jul 2024 14:51:39 +0200 Subject: [PATCH] feat: await initial values while initializing ios core --- ios/platform/Platform_iOS.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ios/platform/Platform_iOS.mm b/ios/platform/Platform_iOS.mm index 9b14f773..55bc3742 100644 --- a/ios/platform/Platform_iOS.mm +++ b/ios/platform/Platform_iOS.mm @@ -81,6 +81,7 @@ - (void)makeShared:(void*)runtime { return [self setRootViewBackgroundColor:color alpha:alpha]; }); + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); dispatch_async(dispatch_get_main_queue(), ^{ Screen screen = [self getScreenDimensions]; @@ -92,7 +93,11 @@ - (void)makeShared:(void*)runtime { unistylesRuntime->pixelRatio = screen.pixelRatio; unistylesRuntime->fontScale = screen.fontScale; unistylesRuntime->rtl = [self isRtl]; + + dispatch_semaphore_signal(semaphore); }); + + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); } - (void)onAppearanceChange:(NSNotification *)notification { @@ -155,7 +160,7 @@ - (bool)isRtl { BOOL hasForcedRtl = [[NSUserDefaults standardUserDefaults] boolForKey:@"RCTI18nUtil_forceRTL"]; // user preferences BOOL isRtl = [UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft; - + return hasForcedRtl || isRtl; }