A SwiftUI-based toast notification system for iOS and macOS applications.
- Toast Notifications: Display temporary messages to users
- Multiple Toast Types: Success, error, warning, and info toasts
- Customizable Styling: Easily customize appearance and behavior
- Error Handling: Built-in error view component
- SwiftUI Native: Fully built with SwiftUI for modern apps
Add MagicAlert as a dependency to your Package.swift:
dependencies: [
.package(url: "https://github.com/nookery/MagicAlert.git", from: "1.0.0")
]Or add it directly in Xcode:
- Go to File → Add Packages...
- Enter the repository URL:
https://github.com/nookery/MagicAlert.git - Choose the version you want to use
Add the .withMagicToast() modifier to your root view and use MagicMessageProvider.shared to display messages:
import SwiftUI
import MagicAlert
struct ContentView: View {
var body: some View {
VStack {
Button("Show Success") {
MagicMessageProvider.shared.success("Operation successful")
}
Button("Show Error") {
MagicMessageProvider.shared.error("Operation failed")
}
Button("Show Info") {
MagicMessageProvider.shared.info("This is an info message")
}
Button("Show Warning") {
MagicMessageProvider.shared.warning("Please be careful")
}
Button("Show Loading") {
MagicMessageProvider.shared.loading("Processing...")
}
}
.withMagicToast() // Enable toast functionality
}
}- iOS 17.0+
- macOS 14.0+
- Swift 5.9+
This project is licensed under the MIT License - see the LICENSE file for details.
