This is an automated email from the ASF dual-hosted git repository.
GitToTheHub pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/cordova-plugin-inappbrowser.git
The following commit(s) were added to refs/heads/master by this push:
new 60a5c73 fix(ios): replace macro `kCloseButtonSystemItem` with static
function to fix XCode warning (#1153)
60a5c73 is described below
commit 60a5c739e25b9938921c3fbc09eaabccb29efb5d
Author: Manuel Beck <[email protected]>
AuthorDate: Fri May 22 13:52:03 2026 +0200
fix(ios): replace macro `kCloseButtonSystemItem` with static function to
fix XCode warning (#1153)
- 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.
- Add note, why `UIBarButtonSystemItemClose` is used since iOS 26 and not
iOS 13
- Generated-By: GPT Codex, XCode
---
src/ios/CDVWKInAppBrowser.m | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/ios/CDVWKInAppBrowser.m b/src/ios/CDVWKInAppBrowser.m
index ddc9505..955d3e7 100644
--- a/src/ios/CDVWKInAppBrowser.m
+++ b/src/ios/CDVWKInAppBrowser.m
@@ -38,7 +38,19 @@
#define IAB_BRIDGE_NAME @"cordova_iab"
-#define kCloseButtonSystemItem (@available(iOS 26.0, *) ?
UIBarButtonSystemItemClose : UIBarButtonSystemItemDone)
+static UIBarButtonSystemItem CDVWKInAppBrowserCloseButtonSystemItem(void)
+{
+ // Since iOS 13 it's possible to use UIBarButtonSystemItemClose
+ // instead of UIBarButtonSystemItemDone which corresponds perfectly
+ // to a close button. Since UIBarButtonSystemItemClose looks akward
+ // on iOS 18 and older, because an X inside a round button is shown,
+ // instead of a text, the close button is only applied since iOS 26.
+ if (@available(iOS 26.0, *)) {
+ return UIBarButtonSystemItemClose;
+ }
+
+ return UIBarButtonSystemItemDone;
+}
#pragma mark CDVWKInAppBrowser
@@ -905,7 +917,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;
@@ -1114,7 +1126,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]