Closed WWSellers closed 2 years ago
Yes, this should never happen. The fix in #96 makes sure we only call the didFailConnectingNFC
method when there's an actual error to pass on. The reasoning for not passing on an error when stopNFCConnection
has been called is that the NFC connection closing without connecting to a YubiKey is expected behaviour at that point.
The
error
argument value can still be nil (null) despite being declared_Nonnull
Swift version
Reproduction:
error
or its members, the app crashes withEXC_BAD_ACCESS (code=1, address=0x0)
Workaround Update on workaround: this only works when SWIFT_OPTIMIZATION_LEVEL = "-Onone". The optimizer will remove the code when set to "-O" for release builds.
App must check if error == nil. If it is, then assume that there is no error, just the app calling stopNFCConnection(). However, the Swift compiler gives a warning:
If a developer is treating warnings as errors, then they will need to make exceptions. (And deal with their security departments.)
Recommendation Specifiy _Nullable for the parameter
Other Notes
The
YKFNFCConnection
membernfcConnectionError
is declared_Nullable
,but is passed to the delegate (
YubiKitManager
)YubiKitManager.m implementation does not declare
_Nullable
or_Nonnull
forerror
but YubiKitManager.h interface does declare _Nonnull
(Adding
_Nonnull
to the implementation did not cause the compiler to give an error)Environment Xcode 13.3 iPhone 13 with iOS 15.4 YubiKit 4.2.0