Skip to content

Fix Swift compiler warnings#311

Closed
ssathy2 wants to merge 1 commit intomainfrom
fix/swift-compiler-warnings
Closed

Fix Swift compiler warnings#311
ssathy2 wants to merge 1 commit intomainfrom
fix/swift-compiler-warnings

Conversation

@ssathy2
Copy link
Copy Markdown
Contributor

@ssathy2 ssathy2 commented Apr 24, 2026

Summary

ConnectButton.swift

The constraint(lessThanOrEqualTo:) call on line 348 was never activated, leaving the "label bottom must not exceed container bottom" relationship dangling. The compiler flagged the unused result. Activate it explicitly — matches the clear intent of the comment above it.

AuthenticationError + SignInWithAppleAuthentication.swift

Apple has added new ASAuthorizationError.Code cases since the SDK was written. Add matching cases to AuthenticationError and map 1:1 so callers see the real Apple-side reason instead of being funneled into a generic .failed / .unknown bucket.

ASAuthorizationError.Code New AuthenticationError case Since
.notInteractive .notInteractive iOS 15.4
.matchedExcludedCredential .matchedExcludedCredential iOS 18.0
.credentialImport .credentialImport iOS 18.2
.credentialExport .credentialExport iOS 18.2

Each Apple case is referenced behind an if #available check so the SDK still builds at its iOS 14.2 deployment target. The original switch (with @unknown default) is kept as a safety net for future Apple additions. This also clears the "switch must be exhaustive" warning that newer compilers raised against the previous iOS-13-only case set.

Test plan

  • Build the SDK against the latest Xcode — no warnings on ConnectButton.swift:348 or SignInWithAppleAuthentication.swift:44
  • Connect button footer layout visually unchanged in the host app
  • Sign-in-with-Apple: canceled / failed / invalidResponse / notHandled / unknown flows surface expected errors
  • Sign-in-with-Apple on iOS 18.2+: passkey exclude-list and credential-import/export error paths surface their new dedicated AuthenticationError cases

@ssathy2 ssathy2 force-pushed the fix/swift-compiler-warnings branch from 92c63e8 to e5f70b3 Compare April 24, 2026 19:05
- ConnectButton: activate the orphaned lessThanOrEqualTo bottom
  constraint so its return value is not ignored.
- AuthenticationError: add .notInteractive, .matchedExcludedCredential,
  .credentialImport, .credentialExport to mirror the new
  ASAuthorizationError.Code cases Apple added in iOS 15.4 / 18 / 18.2.
- SignInWithAppleAuthentication: handle those new codes behind
  availability checks and map each 1:1 to the corresponding
  AuthenticationError so callers see the actual Apple-side reason
  rather than a generic .failed / .unknown bucket.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Swift compiler warnings and improves error fidelity by aligning the SDK’s Sign in with Apple error handling with newer ASAuthorizationError.Code cases while fixing an unused Auto Layout constraint result in ConnectButton.

Changes:

  • Activate a previously-unused “bottom ≤ container bottom” footer label constraint in ConnectButton.
  • Extend AuthenticationError with newer Apple authorization error cases.
  • Map newer ASAuthorizationError.Code values to dedicated AuthenticationError cases behind availability checks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
IFTTT SDK/WebServiceAuthentication.swift Adds new AuthenticationError cases and documentation for newer Apple authorization errors.
IFTTT SDK/SignInWithAppleAuthentication.swift Adds availability-gated mappings from newer ASAuthorizationError.Code cases to AuthenticationError.
IFTTT SDK/ConnectButton.swift Activates a previously unactivated layout constraint to remove a compiler warning and enforce intended layout.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +18 to +25
/// non-interactive context. Mirrors `ASAuthorizationError.notInteractive`
/// (iOS 15.4+).
/// - matchedExcludedCredential: A matched credential was excluded from use.
/// Mirrors `ASAuthorizationError.matchedExcludedCredential` (iOS 18+).
/// - credentialImport: An error occurred importing a credential. Mirrors
/// `ASAuthorizationError.credentialImport` (iOS 18.2+).
/// - credentialExport: An error occurred exporting a credential. Mirrors
/// `ASAuthorizationError.credentialExport` (iOS 18.2+).
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comments reference ASAuthorizationError.notInteractive / .matchedExcludedCredential / .credentialImport / .credentialExport, but these cases live on ASAuthorizationError.Code (e.g., ASAuthorizationError.Code.notInteractive). Updating the symbol names in the documentation will avoid misleading API docs for maintainers/callers.

Suggested change
/// non-interactive context. Mirrors `ASAuthorizationError.notInteractive`
/// (iOS 15.4+).
/// - matchedExcludedCredential: A matched credential was excluded from use.
/// Mirrors `ASAuthorizationError.matchedExcludedCredential` (iOS 18+).
/// - credentialImport: An error occurred importing a credential. Mirrors
/// `ASAuthorizationError.credentialImport` (iOS 18.2+).
/// - credentialExport: An error occurred exporting a credential. Mirrors
/// `ASAuthorizationError.credentialExport` (iOS 18.2+).
/// non-interactive context. Mirrors `ASAuthorizationError.Code.notInteractive`
/// (iOS 15.4+).
/// - matchedExcludedCredential: A matched credential was excluded from use.
/// Mirrors `ASAuthorizationError.Code.matchedExcludedCredential` (iOS 18+).
/// - credentialImport: An error occurred importing a credential. Mirrors
/// `ASAuthorizationError.Code.credentialImport` (iOS 18.2+).
/// - credentialExport: An error occurred exporting a credential. Mirrors
/// `ASAuthorizationError.Code.credentialExport` (iOS 18.2+).

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +48
// Cases added after the SDK's iOS 14.2 deployment target.
// Each is referenced behind an availability check and mapped
// to the matching AuthenticationError case so callers can
// distinguish it from the generic .failed / .unknown bucket.
if #available(iOS 15.4, *), authorizationError.code == .notInteractive {
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AuthenticationError includes .presentationContextInvalid, but didCompleteWithError never maps ASAuthorizationError.Code.presentationContextInvalid to it (it currently falls through to .unknown). Add an explicit mapping so callers can distinguish this error from .unknown/.failed, consistent with the 1:1 mapping intent described in the comment.

Copilot uses AI. Check for mistakes.
footerLabel.bottomAnchor.constraint(lessThanOrEqualTo: footerLabelContainer.bottomAnchor)
footerLabel.bottomAnchor.constraint(lessThanOrEqualTo: footerLabelContainer.bottomAnchor).isActive = true
let breakableBottomConstraint = footerLabel.bottomAnchor.constraint(equalTo: footerLabelContainer.bottomAnchor)
breakableBottomConstraint.priority = .defaultHigh
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breakableBottomConstraint is created and its priority is set, but it’s never activated. If the intent is to keep the footer label bottom-aligned when possible (and let it break when the container is taller), the constraint should be activated; otherwise this constraint has no effect and the label may not pin to the container bottom even when it could.

Suggested change
breakableBottomConstraint.priority = .defaultHigh
breakableBottomConstraint.priority = .defaultHigh
breakableBottomConstraint.isActive = true

Copilot uses AI. Check for mistakes.
@ssathy2
Copy link
Copy Markdown
Contributor Author

ssathy2 commented Apr 27, 2026

Bundling these changes into #312 instead — the PR-311 commit (with the three Copilot review fixes applied: ASAuthorizationError.Code doc references, explicit .presentationContextInvalid mapping, and activating breakableBottomConstraint) has been cherry-picked onto the #312 branch. Closing this in favor of #312.

@ssathy2 ssathy2 closed this Apr 27, 2026
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