-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Swift): Nullability stuff broke Swift compatibility #1521
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1521 +/- ##
=======================================
Coverage 81.41% 81.41%
=======================================
Files 16 16
Lines 1862 1862
=======================================
Hits 1516 1516
Misses 346 346 ☔ View full report in Codecov by Sentry. |
There is warnings with the build though:
|
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 🙃
89efb6f
to
b4d8d75
Compare
Good catch, those warnings should be fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Ran
npm t
, passed, and no warnings. - Built the sample app successfully with no warnings.
- Built the
mobilespec
app successfully with no warnings from CordovaLib.
Platforms affected
iOS
Motivation and Context
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.Description
You aren't allowed to combine
weak
andnonnull
, and all the properties in CDVPlugin are weak, so just... don't wrap it inASSUME_NONNULL
to make life easier for everyone 🙃Testing
Tested with mobilespec (which fails on master and passes with this change)
Checklist