1 min read

SFSafeSymbols: Type-Safe Access to Apple’s SF Symbols in Swift

SFSafeSymbols: Type-Safe Access to Apple’s SF Symbols in Swift
Photo by Harpal Singh / Unsplash

Apple’s SF Symbols offer over 6,000 system icons designed to integrate seamlessly with the San Francisco font. While powerful, referencing symbols by raw strings like "heart.fill" introduces the risk of typos, lack of autocomplete, and runtime errors.

SFSafeSymbols solves this by providing type-safe, Swift-native access to SF Symbols, making development faster, safer, and more enjoyable.

🚀 What is SFSafeSymbols?

SFSafeSymbols is a Swift library that exposes Apple’s SF Symbols as static constants. Instead of writing raw symbol strings, you use structured, type-safe enums that take advantage of compile-time validation and full Xcode autocompletion.

It supports all major Apple platforms: iOS, macOS, watchOS, and tvOS.

🛠️ Installation (Swift Package Manager)

  1. In Xcode, go to File → Add Packages....
  2. Enter the SFSafeSymbols package URL.
  3. Choose the version and add it to your project.

That’s it—you’re ready to use SF Symbols with confidence and safety.

📦 Usage in SwiftUI

After importing the module, symbols can be accessed using dot notation. For example:

import SFSafeSymbols
import SwiftUI

Image(systemSymbol: .heartFill)

You can also use it seamlessly with common SwiftUI components like Label and Button:

Label("Favorites", systemSymbol: .heartFill)

Button("Like", systemSymbol: .heartFill) {
    // Perform action
}

Each symbol is mapped to a Swift-friendly property:

  • "heart.fill" → .heartFill
  • "11.circle.fill" → ._11CircleFill

🎯 Why Use SFSafeSymbols?

  • Type Safety – Catch mistakes at compile time.
  • Autocomplete Support – Easily find the right icon using Xcode suggestions.
  • Cleaner Code – No more string literals scattered through your views.
  • Fewer Bugs – Eliminate typos and invalid symbol names.

✨ Final Thoughts

SFSafeSymbols brings clarity, reliability, and elegance to SF Symbols integration. If you’re building SwiftUI apps and want to avoid the risks of string-based symbols, this library is a must-have.