This repository integrates Lucide Icons and makes them available through the Swift Package Manager (SPM). With this package, you can easily use Lucide icons in your macOS and iOS applications.
To install this package using Swift Package Manager, follow these steps:
- Open your Xcode project.
- Select your project in the Project Navigator.
- Choose the
Package Dependencies
tab. - Click the
+
button to add a new package dependency. - Enter the URL of this repository:
https://github.com/yourusername/lucide-icons-swift.git
. - Select the version you want to use, then click
Add Package
.
After installing the package, you can start using Lucide icons in your project.
In your Swift files, import the package:
import LucideIcons
For iOS, the UIImage
extension provides a convenient initializer that loads images by their Lucide ID directly from the module's bundle:
import UIKit
let image: UIImage = Lucide.tada
if let icon: UIImage? = .init(lucideId: "tada") {
// Use your icon
}
For macOS, the NSImage extension offers a static function that fetches images by their Lucide ID from the module’s bundle:
import AppKit
let image: NSImage = Lucide.tada
if let icon = NSImage.image(lucideId: "yourIconId") {
// Use your icon
}
import SwiftUI
import LucideIcons
struct ContentView: View {
var body: some View {
VStack {
Image(nsImage: Lucide.tada) // For macOS
Image(uiImage: Lucide.tada) // For iOS
Text("Hello, Lucide Icons!")
}
}
}
struct ContentView: View {
var body: some View {
#if canImport(UIKit)
if let uiImage = UIImage(lucideId: "tada") {
Image(uiImage: uiImage)
}
#elseif canImport(AppKit)
if let nsImage = NSImage.image(lucideId: "tada") {
Image(nsImage: nsImage)
}
#endif
}
}
You can view all available icons at lucide.dev/icons.
Enjoy using Lucide Icons in your Swift projects!