<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Also noticed that when Xcode prompts to fill the missing case statements, it fills it with the deprecated TouchID case statements (in an iOS 11 project).<div class=""><br class=""></div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 5 Nov 2017, at 5:14 PM, Dennis Weissmann via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><span class=""></span></div><div class="">Hi Charles,<div class=""><br class=""></div><div class="">You are right (the `default` case would not catch the deprecated values but only new ones introduced in future releases), but the compiler doesn’t seem to know that :(</div><div class=""><br class="">But now that you say it, one approach could be to pattern match the raw values (and, well, have a default clause, which I really want to avoid) 🤔<br class=""><br class=""><div class="">- Dennis<br class=""><div class=""><br class=""></div><div class="">Sent from my iPhone</div></div><div class=""><br class="">On 4. Nov 2017, at 10:42 PM, Charles Srstka &lt;<a href="mailto:cocoadev@charlessoft.com" class="">cocoadev@charlessoft.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><blockquote type="cite" class="">On Nov 4, 2017, at 9:38 AM, Dennis Weissmann via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""></blockquote><div class=""><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi swift-users,<div class=""><br class=""></div><div class="">In a project (iOS 11 only) we use Touch ID for authentication and handle errors like so:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="color: #ba2da2" class="">private</span> <span style="color: #ba2da2" class="">func</span> handleLocalAuthenticationError(<span style="color: #ba2da2" class="">_</span> error: <span style="color: #703daa" class="">LAError</span>) {</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">switch</span> error.<span style="color: #703daa" class="">code</span> {</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(62, 30, 129);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>userCancel<span style="" class="">, .</span>appCancel<span style="" class="">, .</span>systemCancel<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle cancelation</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(62, 30, 129);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>authenticationFailed<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle failure</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(62, 30, 129);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>passcodeNotSet<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle passcode absence</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(62, 30, 129);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>touchIDNotEnrolled<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle no Touch ID enrollment</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(62, 30, 129);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>touchIDNotAvailable<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle no Touch ID availabe</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(62, 30, 129);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>touchIDLockout<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle Touch ID Lockout</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(62, 30, 129);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>userFallback<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle user fallback</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(62, 30, 129);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>invalidContext<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle failure with invalid context</div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(62, 30, 129);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>notInteractive<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle no interaction allowed error</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class="">}</div><div class=""><br class=""></div></div></div></div><div class="">This worked fine until recently, when with the release of iOS 11 and the introduction of Face ID, `.touchIDLockout`, `.touchIDNotEnrolled` and `.touchIDNotAvailable` were deprecated in favor of the newly introduced `.biometryLockout`, `.biometryNotEnrolled` and `.biometryNotAvailable`.</div><div class=""><br class=""></div><div class="">When we link against the latest SDK we need to add those in order to compile (which is obviously good).</div><div class=""><br class=""></div><div class="">Now when we add those cases, the compiler shows the following warnings:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px 0px 0px 12px; text-indent: -12px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&lt;unknown&gt;:0: warning: 'touchIDLockout' was deprecated in iOS 11.0: use LAErrorBiometryLockout</div><div style="margin: 0px 0px 0px 12px; text-indent: -12px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&lt;unknown&gt;:0: warning: 'touchIDNotEnrolled' was deprecated in iOS 11.0: use LAErrorBiometryNotEnrolled</div><div style="margin: 0px 0px 0px 12px; text-indent: -12px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&lt;unknown&gt;:0: warning: 'touchIDNotAvailable' was deprecated in iOS 11.0: use LAErrorBiometryNotAvailable</div></div><div class=""><br class=""></div><div class="">The problem here is, that we can't remove the old ones and replace them with their new variants because for Swift the enum is then not exhaustive (which also makes sense, they're only deprecated, not removed after all).</div><div class=""><br class=""></div><div class="">Even though not optimal (read "really bad because not exhaustive") I thought about removing the old cases and adding a default label:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">private</span> <span style="color: #ba2da2" class="">func</span> handleLocalAuthenticationError(<span style="color: #ba2da2" class="">_</span> error: <span style="color: #703daa" class="">LAError</span>) {</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">switch</span> error.<span style="color: #703daa" class="">code</span> {</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>userCancel<span style="" class="">, .</span>appCancel<span style="" class="">, .</span>systemCancel<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle cancelation</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>authenticationFailed<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle failure</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>passcodeNotSet<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle passcode absence</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>biometryNotEnrolled<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle no biometry enrollment</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>biometryNotAvailable<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle no biometry availabe</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>biometryLockout<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle biometry Lockout</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>userFallback<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle user fallback</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>invalidContext<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle failure with invalid context</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(62, 30, 129); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span><span style="text-decoration: underline ; color: #ba2da2" class="">c</span><span style="color: #ba2da2" class="">ase</span><span style="" class=""> .</span>notInteractive<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// Handle no interaction allowed error</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; </span>default<span style="" class="">:</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span>// hopefully only deprecated cases</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">break</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="text-decoration: underline" class="">}</span></div></div><div class=""><br class=""></div><div class="">However, in this case the compiler warns that "Default will never be executed".</div><div class=""><br class=""></div><div class="">Is there any way of getting rid of these warnings (preferably the first 3 so that we don't have to have default clause)?</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">- Dennis&nbsp;</div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote><br class=""></div><div class="">Hi Dennis,</div><div class=""><br class=""></div><div class="">.touchIDLockout, .touchIDNotAvailable, and .touchIDNotEnrolled have the same rawValue as .biometryLockout, .biometryNotAvailable, and .biometryNotEnrolled. So if you handle the latter, it’ll also handle the former.</div><div class=""><br class=""></div><div class="">Charles</div><br class=""></div></blockquote></div></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></div></body></html>