Skip to content

Commit 89efb6f

Browse files
committed
fix(Swift): Nullability stuff broke Swift compatibility
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 🙃
1 parent 7fa0b8c commit 89efb6f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

CordovaLib/include/Cordova/CDVPlugin.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ typedef int CDVWebViewNavigationType;
4242
@end
4343
#endif
4444

45-
NS_ASSUME_NONNULL_BEGIN
46-
4745
extern const NSNotificationName CDVPageDidLoadNotification;
4846
extern const NSNotificationName CDVPluginHandleOpenURLNotification;
4947
extern const NSNotificationName CDVPluginHandleOpenURLWithAppSourceAndAnnotationNotification CDV_DEPRECATED(8, "Find sourceApplication and annotations in the userInfo of the CDVPluginHandleOpenURLNotification notification.");
@@ -68,8 +66,8 @@ extern const NSNotificationName CDVViewWillTransitionToSizeNotification;
6866

6967
- (void)pluginInitialize;
7068

71-
- (void)handleOpenURL:(NSNotification*)notification;
72-
- (void)handleOpenURLWithApplicationSourceAndAnnotation:(NSNotification*)notification CDV_DEPRECATED(8, "Use the handleOpenUrl method and the notification userInfo data.");
69+
- (void)handleOpenURL:(nonnull NSNotification*)notification;
70+
- (void)handleOpenURLWithApplicationSourceAndAnnotation:(nonnull NSNotification*)notification CDV_DEPRECATED(8, "Use the handleOpenUrl method and the notification userInfo data.");
7371
- (void)onAppTerminate;
7472
- (void)onMemoryWarning;
7573
- (void)onReset;
@@ -89,6 +87,8 @@ extern const NSNotificationName CDVViewWillTransitionToSizeNotification;
8987

9088
#pragma mark - Plugin protocols
9189

90+
NS_ASSUME_NONNULL_BEGIN
91+
9292
/**
9393
A protocol for Cordova plugins to intercept and respond to server
9494
authentication challenges through WebKit.

0 commit comments

Comments
 (0)