Closed dpogue closed 1 year ago
Merging #1295 (39b3fd4) into master (2c86d1a) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #1295 +/- ##
=======================================
Coverage 78.45% 78.45%
=======================================
Files 15 15
Lines 1778 1778
=======================================
Hits 1395 1395
Misses 383 383
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Platforms affected
iOS
Motivation and Context
Fixes #1288
Description
This ensures that the default
init
method is called for CDVPlugin subclasses, to allow Swift initializers to run as expected.Aside: I still feel like
NS_DESIGNATED_INITIALIZER
would be the theoretically correct way to solve this, but that doesn't work when our designated initializer with the webview is part of private implementation details (your designated initializer must be part of your public API surface). The risk is that someone could (in their own code) do[[MyCordovaPlugin alloc] init]
and try to construct a plugin instance without providing the webview engine, and lead to all sorts of weird issues.However, that problem already existed and people don't seem to be shooting themselves in the foot with it (or at least, not complaining here when they do), so it's probably better to fix the issue that is impacting people even if the solution isn't theoretically perfect.
Testing
Added a unit test which ensures that an init-time property in a Swift plugin is correctly set after the plugin has been initialized. This test case fails without the changes to CDVPlugin.m.
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)