Skip to content

Commit 55e5de4

Browse files
committed
fix(macos): build fixes after 0.85 merge
Targeted compile fixes uncovered while bringing up RNTester-macOS against the merged 0.85-stable tree: - RCTUtils.h: drop duplicate RCTUIStatusBarManager decl; close outstanding #if !TARGET_OS_OSX around RCTPresentedViewController + nested !TARGET_OS_TV around RCTUIStatusBarManager. - RCTUIManager.mm: wrap namedOrientationDidChange in #if TARGET_OS_IOS (uses UIDevice.orientation); switch new-arch stub @implementation block to RCTPlatformView/RCTUIView typedefs to match the macOS-fork header signatures. - RCTFrameTimingsObserver.mm: new 0.85 file using UIKit/CADisplayLink. Wrap iOS impl in #if !TARGET_OS_OSX and add macOS no-op stub @implementation so the @interface in the .h has a definition. - RCTBackedTextInputDelegateAdapter.mm: remove two leftover #endif directives left over from the merge (no matching #if). - RCTActivityIndicatorView.m: move the macOS RCTActivityIndicatorView category extension inside #ifndef RCT_REMOVE_LEGACY_ARCH so the base @interface (declared only in the legacy block) is visible. - RCTView.m: guard accessibilityElementsHidden behind !TARGET_OS_OSX (NSView has no such property) and guard [RCTTextView class] dispatch behind #ifndef RCT_REMOVE_LEGACY_ARCH (RCTTextView is legacy-only). - RCTImageUtils.mm: wrap UIImageOrientationFromCGImagePropertyOrientation helper + the in-function UIImageOrientation usage in #if !TARGET_OS_OSX (NSImage path doesn't use UIImageOrientation). - RCTRedBox+Internal.h: replace #import <UIKit/UIKit.h> with the fork's cross-platform <React/RCTUIKit.h> umbrella. - RCTLogBoxView.mm: guard macOS layoutIfNeeded's [_surface setSize:...] behind #ifndef RCT_REMOVE_LEGACY_ARCH (_surface only exists in legacy block).
1 parent c34445f commit 55e5de4

9 files changed

Lines changed: 52 additions & 24 deletions

File tree

packages/react-native/Libraries/Image/RCTImageUtils.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static CGImagePropertyOrientation CGImagePropertyOrientationFromUIImageOrientati
5959
}
6060
#endif // [macOS]
6161

62+
#if !TARGET_OS_OSX // [macOS]
6263
static UIImageOrientation UIImageOrientationFromCGImagePropertyOrientation(CGImagePropertyOrientation imageOrientation)
6364
{
6465
switch (imageOrientation) {
@@ -82,6 +83,7 @@ static UIImageOrientation UIImageOrientationFromCGImagePropertyOrientation(CGIma
8283
return UIImageOrientationUp;
8384
}
8485
}
86+
#endif // [macOS]
8587

8688
CGRect RCTTargetRect(CGSize sourceSize, CGSize destSize, CGFloat destScale, RCTResizeMode resizeMode)
8789
{
@@ -326,7 +328,9 @@ BOOL RCTUpscalingRequired(
326328
CGImageRef imageRef;
327329
BOOL createThumbnail = targetPixelSize.width != 0 && targetPixelSize.height != 0 &&
328330
(sourceSize.width > targetPixelSize.width || sourceSize.height > targetPixelSize.height);
331+
#if !TARGET_OS_OSX // [macOS]
329332
UIImageOrientation orientation = UIImageOrientationUp;
333+
#endif // [macOS]
330334

331335
if (createThumbnail) {
332336
CGFloat maxPixelSize = fmax(targetPixelSize.width, targetPixelSize.height);
@@ -353,10 +357,14 @@ BOOL RCTUpscalingRequired(
353357
// Unlike `CGImageSourceCreateThumbnailAtIndex` (with `kCGImageSourceCreateThumbnailWithTransform` set to YES),
354358
// `CGImageSourceCreateImageAtIndex` doesn't rotate the image to keep the orientation, so we'll need to pass
355359
// the actual orientation (if present) to the `UIImage` initializer
360+
#if !TARGET_OS_OSX // [macOS]
356361
if (orientationNum) {
357362
orientation = UIImageOrientationFromCGImagePropertyOrientation(
358363
(CGImagePropertyOrientation)[orientationNum unsignedIntValue]);
359364
}
365+
#else // [macOS
366+
(void)orientationNum;
367+
#endif // macOS]
360368
}
361369

362370
CFRelease(sourceRef);

packages/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ - (void)textFieldDidChangeSelection:(NSTextField *)textField
306306
}
307307
#endif // macOS]
308308

309-
#endif
310-
311309
@end
312310

313311
#pragma mark - RCTBackedTextViewDelegateAdapter (for UITextView)
@@ -601,6 +599,4 @@ - (bool)_shouldAcceptDrop:(id<UITextDropRequest>)drop
601599
}
602600
#endif // macOS]
603601

604-
#endif
605-
606602
@end

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ RCT_EXTERN RCTPlatformApplication *__nullable RCTSharedApplication(void); // [ma
9898
// or view controller
9999
RCT_EXTERN RCTPlatformWindow *__nullable RCTKeyWindow(void); // [macOS]
100100

101-
#if !TARGET_OS_OSX // [macOS]
102-
// Returns UIStatusBarManager to get it's configuration info.
103-
RCT_EXTERN UIStatusBarManager *__nullable RCTUIStatusBarManager(void);
104-
#endif // [macOS]
105-
106101
#if !TARGET_OS_OSX // [macOS]
107102
// Returns the presented view controller, useful if you need
108103
// e.g. to present a modal view controller or alert over it
@@ -111,6 +106,7 @@ RCT_EXTERN UIViewController *__nullable RCTPresentedViewController(void);
111106
// Retrieve current window UIStatusBarManager
112107
#if !TARGET_OS_TV
113108
RCT_EXTERN UIStatusBarManager *__nullable RCTUIStatusBarManager(void) API_AVAILABLE(ios(13));
109+
#endif // !TARGET_OS_TV
114110
#endif // [macOS]
115111

116112
// Does this device support force touch (aka 3D Touch)?

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ - (void)layoutIfNeeded
116116
[super layoutIfNeeded];
117117
NSRect frame = NSMakeRect(self.frame.origin.x, self.frame.origin.y, 600, 800);
118118
[self setFrame:frame display:NO];
119+
#ifndef RCT_REMOVE_LEGACY_ARCH
119120
[_surface setSize:self.frame.size];
121+
#endif // RCT_REMOVE_LEGACY_ARCH
120122
}
121123
#endif // macOS]
122124

packages/react-native/React/CoreModules/RCTRedBox+Internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
#import <React/RCTDefines.h>
9-
#import <UIKit/UIKit.h>
9+
#import <React/RCTUIKit.h> // [macOS]
1010

1111
#if RCT_DEV_MENU
1212

packages/react-native/React/DevSupport/RCTFrameTimingsObserver.mm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#import "RCTFrameTimingsObserver.h"
99

10+
#if !TARGET_OS_OSX // [macOS] iOS-only screenshot/CADisplayLink frame timings
1011
#import <UIKit/UIKit.h>
1112

1213
#import <mach/thread_act.h>
@@ -296,3 +297,23 @@ - (UIWindow *)_getKeyWindow
296297
}
297298

298299
@end
300+
#else // [macOS macOS no-op stub
301+
@implementation RCTFrameTimingsObserver
302+
303+
#ifdef __cplusplus
304+
- (instancetype)initWithScreenshotsEnabled:(BOOL)screenshotsEnabled callback:(RCTFrameTimingCallback)callback
305+
{
306+
return [super init];
307+
}
308+
#endif
309+
310+
- (void)start
311+
{
312+
}
313+
314+
- (void)stop
315+
{
316+
}
317+
318+
@end
319+
#endif // macOS]

packages/react-native/React/Modules/RCTUIManager.mm

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ - (void)didReceiveNewContentSizeMultiplier
373373
}
374374
#endif // [macOS] [visionOS]
375375

376+
#if TARGET_OS_IOS // [macOS] [visionOS]
376377
- (void)namedOrientationDidChange
377378
{
378379
NSDictionary *orientationEvent = deviceOrientationEventBody([UIDevice currentDevice].orientation);
@@ -386,7 +387,7 @@ - (void)namedOrientationDidChange
386387
body:orientationEvent];
387388
#pragma clang diagnostic pop
388389
}
389-
#endif
390+
#endif // [macOS] [visionOS]
390391

391392
- (dispatch_queue_t)methodQueue
392393
{
@@ -1687,11 +1688,11 @@ - (void)registerRootViewTag:(NSNumber *)rootTag
16871688
{
16881689
}
16891690

1690-
- (void)registerRootView:(UIView *)rootView
1691+
- (void)registerRootView:(RCTUIView *)rootView // [macOS]
16911692
{
16921693
}
16931694

1694-
- (UIView *)viewForReactTag:(NSNumber *)reactTag
1695+
- (RCTPlatformView *)viewForReactTag:(NSNumber *)reactTag // [macOS]
16951696
{
16961697
return nil;
16971698
}
@@ -1710,19 +1711,19 @@ - (RCTShadowView *)shadowViewForReactTag:(NSNumber *)reactTag
17101711
return nil;
17111712
}
17121713

1713-
- (void)setAvailableSize:(CGSize)availableSize forRootView:(UIView *)rootView
1714+
- (void)setAvailableSize:(CGSize)availableSize forRootView:(RCTUIView *)rootView // [macOS]
17141715
{
17151716
}
17161717

1717-
- (void)setLocalData:(NSObject *)localData forView:(UIView *)view
1718+
- (void)setLocalData:(NSObject *)localData forView:(RCTPlatformView *)view // [macOS]
17181719
{
17191720
}
17201721

1721-
- (void)setSize:(CGSize)size forView:(UIView *)view
1722+
- (void)setSize:(CGSize)size forView:(RCTPlatformView *)view // [macOS]
17221723
{
17231724
}
17241725

1725-
- (void)setIntrinsicContentSize:(CGSize)intrinsicContentSize forView:(UIView *)view
1726+
- (void)setIntrinsicContentSize:(CGSize)intrinsicContentSize forView:(RCTPlatformView *)view // [macOS]
17261727
{
17271728
}
17281729

@@ -1742,24 +1743,24 @@ - (void)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag viewName:(NSStrin
17421743
{
17431744
}
17441745

1745-
- (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^__strong)(UIView *__strong))completion
1746+
- (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^__strong)(RCTPlatformView *__strong))completion // [macOS]
17461747
{
17471748
}
17481749

1749-
- (UIView *)viewForNativeID:(NSString *)nativeID withRootTag:(NSNumber *)rootTag
1750+
- (RCTPlatformView *)viewForNativeID:(NSString *)nativeID withRootTag:(NSNumber *)rootTag // [macOS]
17501751
{
17511752
return nil;
17521753
}
17531754

1754-
- (void)setNativeID:(NSString *)nativeID forView:(UIView *)view
1755+
- (void)setNativeID:(NSString *)nativeID forView:(RCTPlatformView *)view // [macOS]
17551756
{
17561757
}
17571758

17581759
- (void)setNeedsLayout
17591760
{
17601761
}
17611762

1762-
+ (UIView *)JSResponder
1763+
+ (RCTPlatformView *)JSResponder // [macOS]
17631764
{
17641765
return nil;
17651766
}

packages/react-native/React/Views/RCTActivityIndicatorView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#import "RCTActivityIndicatorView.h"
99

10+
#ifndef RCT_REMOVE_LEGACY_ARCH
11+
1012
#if TARGET_OS_OSX // [macOS
1113
#import <CoreImage/CIFilter.h>
1214
#import <CoreImage/CIVector.h>
@@ -16,8 +18,6 @@ @interface RCTActivityIndicatorView ()
1618
@end
1719
#endif // macOS]
1820

19-
#ifndef RCT_REMOVE_LEGACY_ARCH
20-
2121
@implementation RCTActivityIndicatorView {
2222
}
2323

packages/react-native/React/Views/RCTView.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,25 @@ - (RCTPlatformView *)react_findClipView // [macOS]
108108
// Result string is initialized lazily to prevent useless but costly allocations.
109109
NSMutableString *str = nil;
110110
for (RCTUIView *subview in view.subviews) { // [macOS]
111+
#if !TARGET_OS_OSX // [macOS]
111112
// Skip subviews that have accessibilityElementsHidden set to YES
112113
if (subview.accessibilityElementsHidden) {
113114
continue;
114115
}
115-
#if !TARGET_OS_OSX // [macOS]
116116
NSString *label = subview.accessibilityLabel;
117117
#else // [macOS
118118
NSString *label;
119+
#ifndef RCT_REMOVE_LEGACY_ARCH
119120
if ([subview isKindOfClass:[RCTTextView class]]) {
120121
// on macOS VoiceOver a text element will always have its accessibilityValue read, but will only read it's accessibilityLabel if it's value is set.
121122
// the macOS RCTTextView accessibilityValue will return its accessibilityLabel if set otherwise return its text.
122123
label = subview.accessibilityValue;
123124
} else {
124125
label = subview.accessibilityLabel;
125126
}
127+
#else
128+
label = subview.accessibilityLabel;
129+
#endif // RCT_REMOVE_LEGACY_ARCH
126130
#endif // macOS]
127131
if (!label) {
128132
label = RCTRecursiveAccessibilityLabel(subview);

0 commit comments

Comments
 (0)