Remove warning for unhandled NWError cases - #882
Merged
Merged
Conversation
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.
pm47
approved these changes
Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR removes a compile-time warning in the ios-crypto project, in
NativeSocket.swift.Warning example:
Should unhandled cases trigger a warning?
The
@unknownannotation has been explicitly added in theswitchto 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
wifiAwarecase would either mean:wifiAwareon Xcode26+, while keeping the compile-time warning on older Xcode versions.It's not worth it. So instead I removed
@unknownand just keepdefault:. This way, unhandled cases will use the default log.