Skip to content

Commit e28f954

Browse files
Fix iOS and visionOS build issues
1 parent 7f3436c commit e28f954

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

packages/react-native/React/Base/RCTUtils.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,12 @@ CGFloat RCTFontSizeMultiplier(void)
403403
return mapping[RCTSharedApplication().preferredContentSizeCategory].floatValue;
404404
}
405405

406+
#if TARGET_OS_IOS // [visionOS]
406407
UIDeviceOrientation RCTDeviceOrientation(void)
407408
{
408409
return [[UIDevice currentDevice] orientation];
409410
}
411+
#endif // visionOS]
410412

411413
CGSize RCTScreenSize(void)
412414
{
@@ -422,12 +424,16 @@ CGSize RCTScreenSize(void)
422424
portraitSize = CGSizeMake(MIN(screenSize.width, screenSize.height), MAX(screenSize.width, screenSize.height));
423425
});
424426
});
425-
427+
#if TARGET_OS_IOS // [visionOS]
426428
if (UIDeviceOrientationIsLandscape(RCTDeviceOrientation())) {
427429
return CGSizeMake(portraitSize.height, portraitSize.width);
428430
} else {
429431
return CGSizeMake(portraitSize.width, portraitSize.height);
430432
}
433+
#else // [visionOS
434+
return CGSizeMake(portraitSize.width, portraitSize.height);
435+
#endif // visionOS]
436+
431437
}
432438
#else // [macOS
433439
CGFloat RCTScreenScale(void)

packages/react-native/React/CoreModules/RCTDeviceInfo.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static BOOL RCTIsIPhoneNotched()
188188
UIScreen *mainScreen = UIScreen.mainScreen;
189189
CGSize screenSize = mainScreen.bounds.size;
190190
#else // [visionOS
191-
CGSize screenSize = NSZeroSize;
191+
CGSize screenSize = CGSizeZero;
192192
#endif // visionOS]
193193
UIView *mainWindow = RCTKeyWindow();
194194
#else // [macOS

packages/react-native/React/CoreModules/RCTStatusBarManager.mm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ - (void)applicationWillChangeStatusBarFrame:(NSNotification *)notification
147147
{
148148
[self emitEvent:kStatusBarFrameWillChange forNotification:notification];
149149
}
150-
#endif
151150

152151
RCT_EXPORT_METHOD(getHeight : (RCTResponseSenderBlock)callback)
153152
{

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,9 @@ - (void)invalidateLayer
11151115
// rendering incorrectly on iOS, iOS apps in compatibility mode on visionOS, but not on visionOS.
11161116
// To work around this, for iOS, we can calculate the border path based on `view.frame` (the
11171117
// superview's coordinate space) instead of view.bounds.
1118-
CGPathRef borderPath = RCTPathCreateWithRoundedRect(self.frame, cornerInsets, NULL);
1118+
CGPathRef borderPath = RCTPathCreateWithRoundedRect(self.frame, cornerInsets, NULL, NO);
11191119
#else // TARGET_OS_VISION
1120-
CGPathRef borderPath = RCTPathCreateWithRoundedRect(self.bounds, cornerInsets, NULL);
1120+
CGPathRef borderPath = RCTPathCreateWithRoundedRect(self.bounds, cornerInsets, NULL, NO);
11211121
#endif
11221122
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithCGPath:borderPath];
11231123
CGPathRelease(borderPath);

packages/react-native/React/Fabric/Utils/RCTBoxShadow.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ static CGColorRef colorRefFromSharedColor(const SharedColor &color)
6767
// more like the web.
6868
shadowLayer.shadowRadius = shadow.blurRadius / 2;
6969
#if !TARGET_OS_OSX // [macOS]
70+
#if !TARGET_OS_VISION // [visionOS]
7071
shadowLayer.contentsScale = [UIScreen mainScreen].scale;
72+
#else // [visionOS
73+
shadowLayer.contentsScale = [UITraitCollection currentTraitCollection].displayScale;
74+
#endif // visionOS]
7175
#endif // [macOS]
7276

7377
return shadowLayer;
@@ -88,7 +92,11 @@ static CGColorRef colorRefFromSharedColor(const SharedColor &color)
8892

8993
CAShapeLayer *mask = [CAShapeLayer new];
9094
#if !TARGET_OS_OSX // [macOS]
95+
#if !TARGET_OS_VISION // [visionOS]
9196
[mask setContentsScale:[UIScreen mainScreen].scale];
97+
#else // [visionOS
98+
[mask setContentsScale:[UITraitCollection currentTraitCollection].displayScale];
99+
#endif // visionOS]
92100
#endif // [macOS]
93101
CGMutablePathRef path = CGPathCreateMutable();
94102
CGPathRef layerPath =

0 commit comments

Comments
 (0)