Error Alert

Presents an alert when an error is present.

Error Alert - iOS Liquid Glass Light Mode Preview

Platform Compatibility

iOS 27.0+ iPadOS 27.0+ macOS 27.0+ watchOS 27.0+ tvOS 27.0+ visionOS 27.0+

Tags

SwiftUI Code

Docs
enum FooError: LocalizedError {
    case bar

    var errorDescription: String? {
        switch self {
            case .bar:
            return "Bar error occurred."
        }
    }
}

@State private var error: FooError? = .bar

var body: some View {
    Text("Foo")
        .alert(error: $error) {
            Button("OK") {
                print("Error nilled")
            }
        }
}

Found an issue or have a suggestion?

Created: June 9, 2026Updated: June 9, 2026
Connect Wizard

Connect Wizard

Unlock hidden App Store Connect analytics

Pre-order