Skip to content

Commit

Permalink
fix(iOS): add missing iOS API availbility checks (#1860)
Browse files Browse the repository at this point in the history
## Description

When adding 

#1843

I've forgotten to add API avaibility checks for method definitions
(usage and declarations were guarded). This caused build problems when
deploying for lower iOS versions.

Fixes #1859

## Changes

Added missing availbility checks.

## Test code and steps to reproduce

Build iOS without having iOS 16 installed (or somehow disabled?).

## Checklist

- [x] Ensured that CI passes
  • Loading branch information
kkafar authored Aug 4, 2023
1 parent d062c91 commit 4694525
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ios/RNSSearchBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
@property (nonatomic) RNSSearchBarPlacement placement;
@property (nonatomic, retain) UISearchController *controller;

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_16_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0 && !TARGET_OS_TV
- (UINavigationItemSearchBarPlacement)placementAsUINavigationItemSearchBarPlacement API_AVAILABLE(ios(16.0))
API_UNAVAILABLE(tvos, watchos);
#endif // Check for iOS >= 16 && !TARGET_OS_TV

#ifdef RCT_NEW_ARCH_ENABLED
#else
Expand Down
6 changes: 5 additions & 1 deletion ios/RNSSearchBar.mm
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ - (void)showCancelButton
#endif
}

- (UINavigationItemSearchBarPlacement)placementAsUINavigationItemSearchBarPlacement
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && defined(__IPHONE_16_0) && \
__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0 && !TARGET_OS_TV
- (UINavigationItemSearchBarPlacement)placementAsUINavigationItemSearchBarPlacement API_AVAILABLE(ios(16.0))
API_UNAVAILABLE(tvos, watchos)
{
switch (_placement) {
case RNSSearchBarPlacementStacked:
Expand All @@ -224,6 +227,7 @@ - (UINavigationItemSearchBarPlacement)placementAsUINavigationItemSearchBarPlacem
return UINavigationItemSearchBarPlacementInline;
}
}
#endif // Check for iOS >= 16 && !TARGET_OS_TV

#pragma mark delegate methods

Expand Down

0 comments on commit 4694525

Please sign in to comment.