Skip to content

Remove warning for unhandled NWError cases - #882

Merged
dpad85 merged 1 commit into
masterfrom
fix-ios-warning
Sep 18, 2026
Merged

dpad85 merged 1 commit into
masterfrom
fix-ios-warning

Conversation

@dpad85

@dpad85 dpad85 commented Sep 17, 2026

Copy link
Copy Markdown
Member

This PR removes a compile-time warning in the ios-crypto project, in NativeSocket.swift.

Warning example:

> Task :lightning-kmp-ios-crypto:buildCryptoMacosx
... ios-crypto/PhoenixCrypto/Classes/NativeSocket.swift:105:5: warning: switch must be exhaustive
        switch error {
        ^
...ios-crypto/PhoenixCrypto/Classes/NativeSocket.swift:105:5: note: add missing case: '.wifiAware(_)'
        switch error {
        ^

Should unhandled cases trigger a warning?

The @unknown annotation has been explicitly added in the switch to warn that an error type is unhandled, and that we should do something about it.

In this case, this type is wifiAware, added by Apple in 2025.

However, I think it does not deserve a warning. The switch actually just helps printing a slightly more precise error log, in debug.

Beside, handling a new case such as wifiAware case would either mean:

  • forcing the project to use Xcode 26+
  • adding many lines of code to handle wifiAware on Xcode26+, while keeping the compile-time warning on older Xcode versions.

It's not worth it. So instead I removed @unknown and just keep default:. This way, unhandled cases will use the default log.

The wifiAware case has been added with macOS 26 (2025). It triggers a
"non-exhaustive switch" warning at compile time, due to the @unknown
annotation.

Handling the wifiAware case is not an option: it would either mean
forcing the project to use Xcode 26+; or adding many lines of code
to avoid the wifiAware warning on Xcode26+ only and provide a
slightly more precise log at runtime. It's not worth it.

Instead we remove @unknown. This means that unhandled cases will use
the default log, and that we will not have a warning at compile time.
@dpad85 dpad85 assigned pm47 and unassigned pm47 Sep 17, 2026
@dpad85
dpad85 requested a review from pm47 September 17, 2026 17:00
@dpad85
dpad85 merged commit 43e4cf1 into master Sep 18, 2026
2 checks passed
@dpad85
dpad85 deleted the fix-ios-warning branch September 18, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants