Skip to content

Commit 4614702

Browse files
authored
fix(iOS): fix build issues when building with -Werror -Wreturn-path (#2497)
## Description Possible build issues. ## Changes - **Add default for resizemode conversion** - **Remove unimplemented and unused method** ## Test code and steps to reproduce CI ## Checklist - [ ] Ensured that CI passes
1 parent 6a95fe7 commit 4614702

11 files changed

+74
-34
lines changed

common/cpp/react/renderer/components/rnscreens/RNSScreenShadowNode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ findHeaderConfigChild(const YogaLayoutableShadowNode &screenShadowNode) {
2626
return {};
2727
}
2828

29+
#ifdef ANDROID
2930
static constexpr const char *kScreenDummyLayoutHelperClass =
3031
"com/swmansion/rnscreens/utils/ScreenDummyLayoutHelper";
3132

32-
#ifdef ANDROID
3333
std::optional<float> findHeaderHeight(
3434
const int fontSize,
3535
const bool isTitleEmpty) {

ios/RNSConvert.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ namespace react = facebook::react;
4343

4444
+ (RNSSearchBarPlacement)RNSScreenSearchBarPlacementFromCppEquivalent:(react::RNSSearchBarPlacement)placement;
4545

46-
+ (NSMutableArray<NSNumber *> *)NSNumberMutableArrayFromFloatVector:(const std::vector<CGFloat> &)vector;
47-
4846
+ (NSMutableArray<NSNumber *> *)arrayFromVector:(const std::vector<CGFloat> &)vector;
4947

5048
+ (RNSBlurEffectStyle)RNSBlurEffectStyleFromCppEquivalent:(react::RNSScreenStackHeaderConfigBlurEffect)blurEffect;

ios/RNSFullWindowOverlay.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#import <UIKit/UIKit.h>
22

3+
#import "RNSDefines.h"
34
#import "RNSFullWindowOverlay.h"
45

56
#ifdef RCT_NEW_ARCH_ENABLED
@@ -198,13 +199,16 @@ - (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childCompo
198199
[childComponentView removeFromSuperview];
199200
}
200201

202+
RNS_IGNORE_SUPER_CALL_BEGIN
203+
// We do not set frame for ouselves, but rather for the container.
201204
- (void)updateLayoutMetrics:(react::LayoutMetrics const &)layoutMetrics
202205
oldLayoutMetrics:(react::LayoutMetrics const &)oldLayoutMetrics
203206
{
204207
CGRect frame = RCTCGRectFromRect(layoutMetrics.frame);
205208
_reactFrame = frame;
206209
[_container setFrame:frame];
207210
}
211+
RNS_IGNORE_SUPER_CALL_END
208212

209213
#else
210214
#pragma mark - Paper specific

ios/RNSScreen.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#import "RNSScreenStack.h"
3232
#import "RNSScreenStackHeaderConfig.h"
3333

34+
#import "RNSDefines.h"
3435
#import "UIView+RNSUtility.h"
3536

3637
#ifdef RCT_NEW_ARCH_ENABLED
@@ -136,10 +137,12 @@ - (UIViewController *)reactViewController
136137
}
137138

138139
#ifdef RCT_NEW_ARCH_ENABLED
140+
RNS_IGNORE_SUPER_CALL_BEGIN
139141
- (NSArray<UIView *> *)reactSubviews
140142
{
141143
return _reactSubviews;
142144
}
145+
RNS_IGNORE_SUPER_CALL_END
143146
#endif
144147

145148
- (void)updateBounds
@@ -374,10 +377,12 @@ - (void)setHomeIndicatorHidden:(BOOL)homeIndicatorHidden
374377
}
375378
#endif
376379

380+
RNS_IGNORE_SUPER_CALL_BEGIN
377381
- (UIView *)reactSuperview
378382
{
379383
return _reactSuperview;
380384
}
385+
RNS_IGNORE_SUPER_CALL_END
381386

382387
/// This is RNSScreenContentWrapperDelegate method, where we do get notified when React did update frame of our child.
383388
- (void)reactDidSetFrame:(CGRect)reactFrame forContentWrapper:(RNSScreenContentWrapper *)contentWrapepr

ios/RNSScreenContainer.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#import "RNSScreenContainer.h"
2+
#import "RNSDefines.h"
23
#import "RNSScreen.h"
34

45
#ifdef RCT_NEW_ARCH_ENABLED
@@ -89,6 +90,9 @@ - (void)markChildUpdated
8990
[self updateContainer];
9091
}
9192

93+
RNS_IGNORE_SUPER_CALL_BEGIN
94+
// We do not call super as we do not want to update UIKit model. It will
95+
// be updated after we receive all mutations.
9296
- (void)insertReactSubview:(RNSScreenView *)subview atIndex:(NSInteger)atIndex
9397
{
9498
subview.reactSuperview = self;
@@ -106,6 +110,7 @@ - (void)removeReactSubview:(RNSScreenView *)subview
106110
{
107111
return _reactSubviews;
108112
}
113+
RNS_IGNORE_SUPER_CALL_END
109114

110115
- (UIViewController *)reactViewController
111116
{

ios/RNSScreenFooter.mm

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,34 @@ - (instancetype)init
2626
- (void)willMoveToSuperview:(UIView *)newSuperview
2727
{
2828
[super willMoveToSuperview:newSuperview];
29-
if ([newSuperview isKindOfClass:RNSScreenView.class]) {
30-
RNSScreenView *screen = (RNSScreenView *)newSuperview;
31-
_parent = (RNSScreenView *)newSuperview;
32-
33-
// [NSLayoutConstraint activateConstraints:@[
34-
// [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom
35-
// relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeBottom multiplier:1.0
36-
// constant:0.0], [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeLeft
37-
// relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0],
38-
// [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual
39-
// toItem:screen attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint
40-
// constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:screen
41-
// attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
42-
// attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self
43-
// attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0], [NSLayoutConstraint
44-
// constraintWithItem:screen attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self
45-
// attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
46-
// attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self
47-
// attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
48-
// attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop
49-
// multiplier:1.0 constant:0.0],
50-
// ]];
51-
// [self setNeedsLayout];
52-
}
29+
// if ([newSuperview isKindOfClass:RNSScreenView.class]) {
30+
// RNSScreenView *screen = (RNSScreenView *)newSuperview;
31+
// _parent = (RNSScreenView *)newSuperview;
32+
33+
// [NSLayoutConstraint activateConstraints:@[
34+
// [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom
35+
// relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeBottom multiplier:1.0
36+
// constant:0.0], [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeLeft
37+
// relatedBy:NSLayoutRelationEqual toItem:screen attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0],
38+
// [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual
39+
// toItem:screen attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint
40+
// constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:screen
41+
// attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
42+
// attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self
43+
// attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0], [NSLayoutConstraint
44+
// constraintWithItem:screen attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self
45+
// attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
46+
// attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self
47+
// attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0], [NSLayoutConstraint constraintWithItem:screen
48+
// attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop
49+
// multiplier:1.0 constant:0.0],
50+
// ]];
51+
// [self setNeedsLayout];
52+
// }
5353
}
5454

5555
- (void)didMoveToSuperview
5656
{
57-
NSLog(@"Adding constraints between %@ and %@", self, _parent);
5857
if (_parent != nil) {
5958
// [NSLayoutConstraint activateConstraints:@[
6059
// [NSLayoutConstraint constraintWithItem:self

ios/RNSScreenStack.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#import "RCTTouchHandler+RNSUtility.h"
2121
#endif // RCT_NEW_ARCH_ENABLED
2222

23+
#import "RNSDefines.h"
2324
#import "RNSPercentDrivenInteractiveTransition.h"
2425
#import "RNSScreen.h"
2526
#import "RNSScreenStack.h"
@@ -290,10 +291,12 @@ - (void)presentationControllerDidDismiss:(UIPresentationController *)presentatio
290291
}
291292
}
292293

294+
RNS_IGNORE_SUPER_CALL_BEGIN
293295
- (NSArray<UIView *> *)reactSubviews
294296
{
295297
return _reactSubviews;
296298
}
299+
RNS_IGNORE_SUPER_CALL_END
297300

298301
- (void)didMoveToWindow
299302
{
@@ -1086,6 +1089,9 @@ - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
10861089

10871090
#endif // !TARGET_OS_TV
10881091

1092+
RNS_IGNORE_SUPER_CALL_BEGIN
1093+
// We hijack the udpates as we don't want to update UIKit model yet.
1094+
// This is done after all mutations are processed.
10891095
- (void)insertReactSubview:(RNSScreenView *)subview atIndex:(NSInteger)atIndex
10901096
{
10911097
if (![subview isKindOfClass:[RNSScreenView class]]) {
@@ -1101,6 +1107,7 @@ - (void)removeReactSubview:(RNSScreenView *)subview
11011107
subview.reactSuperview = nil;
11021108
[_reactSubviews removeObject:subview];
11031109
}
1110+
RNS_IGNORE_SUPER_CALL_END
11041111

11051112
- (void)didUpdateReactSubviews
11061113
{

ios/RNSScreenStackHeaderConfig.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@interface NSString (RNSStringUtil)
1414

15-
+ (BOOL)RNSisBlank:(NSString *)string;
15+
+ (BOOL)RNSisBlank:(nullable NSString *)string;
1616

1717
@end
1818

@@ -31,6 +31,8 @@
3131
@property (nonatomic) BOOL hide;
3232
#endif
3333

34+
NS_ASSUME_NONNULL_BEGIN
35+
3436
@property (nonatomic, retain) NSString *title;
3537
@property (nonatomic, retain) NSString *titleFontFamily;
3638
@property (nonatomic, retain) NSNumber *titleFontSize;
@@ -58,9 +60,11 @@
5860
@property (nonatomic) UINavigationItemBackButtonDisplayMode backButtonDisplayMode;
5961
@property (nonatomic) RNSBlurEffectStyle blurEffect;
6062

61-
+ (void)willShowViewController:(UIViewController *)vc
63+
NS_ASSUME_NONNULL_END
64+
65+
+ (void)willShowViewController:(nonnull UIViewController *)vc
6266
animated:(BOOL)animated
63-
withConfig:(RNSScreenStackHeaderConfig *)config;
67+
withConfig:(nonnull RNSScreenStackHeaderConfig *)config;
6468

6569
/**
6670
* Allows to send information with insets to the corresponding node in shadow tree.
@@ -132,8 +136,7 @@
132136

133137
@interface RCTConvert (RNSScreenStackHeader)
134138

135-
+ (UIBlurEffectStyle)UIBlurEffectStyle:(id)json;
136-
+ (UISemanticContentAttribute)UISemanticContentAttribute:(id)json;
137-
+ (UINavigationItemBackButtonDisplayMode)UINavigationItemBackButtonDisplayMode:(id)json;
139+
+ (UISemanticContentAttribute)UISemanticContentAttribute:(nonnull id)json;
140+
+ (UINavigationItemBackButtonDisplayMode)UINavigationItemBackButtonDisplayMode:(nonnull id)json;
138141

139142
@end

ios/RNSScreenStackHeaderConfig.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#import <React/RCTImageLoader.h>
2222
#import <React/RCTImageSource.h>
2323
#import "RNSConvert.h"
24+
#import "RNSDefines.h"
2425
#import "RNSScreen.h"
2526
#import "RNSScreenStackHeaderConfig.h"
2627
#import "RNSSearchBar.h"
@@ -113,6 +114,7 @@ - (void)initProps
113114
_blurEffect = RNSBlurEffectStyleNone;
114115
}
115116

117+
RNS_IGNORE_SUPER_CALL_BEGIN
116118
- (UIView *)reactSuperview
117119
{
118120
return _screenView;
@@ -122,6 +124,7 @@ - (UIView *)reactSuperview
122124
{
123125
return _reactSubviews;
124126
}
127+
RNS_IGNORE_SUPER_CALL_END
125128

126129
- (void)removeFromSuperview
127130
{
@@ -785,6 +788,7 @@ + (void)updateViewController:(UIViewController *)vc
785788
}
786789
}
787790

791+
RNS_IGNORE_SUPER_CALL_BEGIN
788792
- (void)insertReactSubview:(RNSScreenStackHeaderSubview *)subview atIndex:(NSInteger)atIndex
789793
{
790794
[_reactSubviews insertObject:subview atIndex:atIndex];
@@ -795,6 +799,7 @@ - (void)removeReactSubview:(RNSScreenStackHeaderSubview *)subview
795799
{
796800
[_reactSubviews removeObject:subview];
797801
}
802+
RNS_IGNORE_SUPER_CALL_BEGIN
798803

799804
- (void)didUpdateReactSubviews
800805
{
@@ -879,6 +884,9 @@ static RCTResizeMode resizeModeFromCppEquiv(react::ImageResizeMode resizeMode)
879884
return RCTResizeModeCenter;
880885
case react::ImageResizeMode::Repeat:
881886
return RCTResizeModeRepeat;
887+
default:
888+
// Both RCTConvert and ImageProps use this as a default as of RN 0.76
889+
return RCTResizeModeStretch;
882890
}
883891
}
884892

ios/RNSScreenStackHeaderSubview.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#import "RNSScreenStackHeaderSubview.h"
22
#import "RNSConvert.h"
3+
#import "RNSDefines.h"
34
#import "RNSScreenStackHeaderConfig.h"
45

56
#ifdef RCT_NEW_ARCH_ENABLED
@@ -86,6 +87,8 @@ - (void)updateProps:(react::Props::Shared const &)props oldProps:(react::Props::
8687
return react::concreteComponentDescriptorProvider<react::RNSScreenStackHeaderSubviewComponentDescriptor>();
8788
}
8889

90+
RNS_IGNORE_SUPER_CALL_BEGIN
91+
// System layouts the subviews.
8992
- (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics
9093
oldLayoutMetrics:(const react::LayoutMetrics &)oldLayoutMetrics
9194
{
@@ -105,6 +108,7 @@ - (void)updateLayoutMetrics:(const react::LayoutMetrics &)layoutMetrics
105108
[self layoutNavigationBarIfNeeded];
106109
}
107110
}
111+
RNS_IGNORE_SUPER_CALL_BEGIN
108112

109113
+ (BOOL)shouldBeRecycled
110114
{

0 commit comments

Comments
 (0)