This is an automated email from the ASF dual-hosted git repository. GitToTheHub pushed a commit to branch pr-fix-replace-macro-kCloseButtonSystemItem-with-static-function in repository https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
commit 73e5b0470ec5ec3d46828eab758d1767e470561c Author: Manuel Beck <[email protected]> AuthorDate: Wed May 20 16:09:53 2026 +0200 fix(ios): replace macro `kCloseButtonSystemItem` with static function to fix XCode warning - XCode complained about the macro replacement `@available does not guard availability here; use if (@available) instead`. Since `if (@available)` cannot be easily added to the macro replacement, the macro is changed to a static function. --- src/ios/CDVWKInAppBrowser.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m index b826c92..4d17b56 100644 --- a/src/ios/CDVWKInAppBrowser.m +++ b/src/ios/CDVWKInAppBrowser.m @@ -38,7 +38,14 @@ #define IAB_BRIDGE_NAME @"cordova_iab" -#define kCloseButtonSystemItem (@available(iOS 26.0, *) ? UIBarButtonSystemItemClose : UIBarButtonSystemItemDone) +static UIBarButtonSystemItem CDVWKInAppBrowserCloseButtonSystemItem(void) +{ + if (@available(iOS 26.0, *)) { + return UIBarButtonSystemItemClose; + } + + return UIBarButtonSystemItemDone; +} #pragma mark CDVWKInAppBrowser @@ -893,7 +900,7 @@ BOOL isExiting = NO; // NOTE: On iOS 26 using `UIBarButtonItem initWithBarButtonSystemItem:` gives constraint warnings, // which is a known UIKit bug. - self.closeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:kCloseButtonSystemItem + self.closeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:CDVWKInAppBrowserCloseButtonSystemItem() target:self action:@selector(close)]; self.closeButton.enabled = YES; @@ -1102,7 +1109,7 @@ BOOL isExiting = NO; // If a custom caption is provided, create a title-based button instead. self.closeButton = nil; // Initialize with title if set, otherwise use the system-localized Close/Done item. - self.closeButton = title != nil ? [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(close)] : [[UIBarButtonItem alloc] initWithBarButtonSystemItem:kCloseButtonSystemItem target:self action:@selector(close)]; + self.closeButton = title != nil ? [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(close)] : [[UIBarButtonItem alloc] initWithBarButtonSystemItem:CDVWKInAppBrowserCloseButtonSystemItem() target:self action:@selector(close)]; self.closeButton.enabled = YES; // If color on closebutton is requested then initialize with that that color, otherwise use initialize with default. self.closeButton.tintColor = colorString != nil ? [self colorFromHexString:colorString] : [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1]; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
