This is an automated email from the ASF dual-hosted git repository.

dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-ios.git


The following commit(s) were added to refs/heads/master by this push:
     new 5cf4d943 fix(Swift): Nullability stuff broke Swift compatibility 
(#1521)
5cf4d943 is described below

commit 5cf4d943d9767bbf69b3ba3ae0e2f2037f0da7bb
Author: Darryl Pogue <dar...@dpogue.ca>
AuthorDate: Fri Jan 17 10:02:17 2025 -0800

    fix(Swift): Nullability stuff broke Swift compatibility (#1521)
    
    CDVPlugin's commandDelegate is a weak pointer, which means technically
    in Swift it should be an optional type that requires unwrapping. For
    some reason, it is not.
    
    If the wrap the CDVPlugin class in the ASSUME_NONNULL macro, Swift
    suddenly starts enforcing that it's an optional, and this breaks all
    existing Swift plugins.
    
    You aren't allowed to combine `weak` and `nonnull`, and all the
    properties in CDVPlugin are weak, so just... don't wrap it in
    ASSUME_NONNULL to make life easier for everyone 🙃
---
 CordovaLib/include/Cordova/CDVPlugin.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/CordovaLib/include/Cordova/CDVPlugin.h 
b/CordovaLib/include/Cordova/CDVPlugin.h
index db4b2cf3..f4575f7c 100644
--- a/CordovaLib/include/Cordova/CDVPlugin.h
+++ b/CordovaLib/include/Cordova/CDVPlugin.h
@@ -32,6 +32,8 @@
 
 typedef int CDVWebViewNavigationType;
 
+NS_ASSUME_NONNULL_BEGIN
+
 #ifndef __swift__
 // This global extension to the UIView class causes issues for Swift subclasses
 // of UIView with their own scrollView properties, so we're removing it from
@@ -42,8 +44,6 @@ typedef int CDVWebViewNavigationType;
 @end
 #endif
 
-NS_ASSUME_NONNULL_BEGIN
-
 extern const NSNotificationName CDVPageDidLoadNotification;
 extern const NSNotificationName CDVPluginHandleOpenURLNotification;
 extern const NSNotificationName 
CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification CDV_DEPRECATED(8, 
"Find sourceApplication and annotations in the userInfo of the 
CDVPluginHandleOpenURLNotification notification.");
@@ -56,6 +56,8 @@ extern const NSNotificationName 
CDVViewWillLayoutSubviewsNotification;
 extern const NSNotificationName CDVViewDidLayoutSubviewsNotification;
 extern const NSNotificationName CDVViewWillTransitionToSizeNotification;
 
+NS_ASSUME_NONNULL_END
+
 @interface CDVPlugin : NSObject {}
 
 @property (nonatomic, readonly, weak) UIView* webView;
@@ -68,8 +70,8 @@ extern const NSNotificationName 
CDVViewWillTransitionToSizeNotification;
 
 - (void)pluginInitialize;
 
-- (void)handleOpenURL:(NSNotification*)notification;
-- 
(void)handleOpenURLWithApplicationSourceAndAnnotation:(NSNotification*)notification
 CDV_DEPRECATED(8, "Use the handleOpenUrl method and the notification userInfo 
data.");
+- (void)handleOpenURL:(nonnull NSNotification*)notification;
+- (void)handleOpenURLWithApplicationSourceAndAnnotation:(nonnull 
NSNotification*)notification CDV_DEPRECATED(8, "Use the handleOpenUrl method 
and the notification userInfo data.");
 - (void)onAppTerminate;
 - (void)onMemoryWarning;
 - (void)onReset;
@@ -83,12 +85,14 @@ extern const NSNotificationName 
CDVViewWillTransitionToSizeNotification;
  - (void) onOrientationDidChange {}
  */
 
-- (id)appDelegate;
+- (nonnull id)appDelegate;
 
 @end
 
 #pragma mark - Plugin protocols
 
+NS_ASSUME_NONNULL_BEGIN
+
 /**
  A protocol for Cordova plugins to intercept and respond to server
  authentication challenges through WebKit.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to