Skip to content

Add symbol availability check API #7

@AprilNEA

Description

@AprilNEA

Problem

There's no way to check if a specific SF Symbol is available on the current macOS version before attempting to render it.

SF Symbols are versioned (v1.0 through v7.x), and newer symbols are only available on newer macOS versions. Currently, if a symbol is unavailable, the render silently returns None.

Proposed Solution

Add an availability check API:

impl SfSymbol {
    /// Check if this symbol is available on the current system
    pub fn is_available(&self) -> bool { ... }
    
    /// Check if SF Symbols are supported at all (macOS 11+)
    pub fn sf_symbols_supported() -> bool { ... }
}

// Usage
if SfSymbol::new("person.badge.clock").is_available() {
    Icon::new("person.badge.clock")
} else {
    Icon::new("person") // Fallback to older symbol
}

Additional: Version-based helpers

The sfsymbols crate already has version information. We could expose this:

impl SfSymbol {
    /// Get the minimum SF Symbols version required for this symbol
    pub fn required_version(&self) -> Option<(u32, u32)> { ... }
    
    /// Get the current system's SF Symbols version
    pub fn system_version() -> (u32, u32) { ... }
}

// Usage with sfsymbols enums
use sfsymbols::SfSymbolV6;

// This could be auto-derived from the enum version
SfSymbolV6::PersonBadgeClock.required_version() // (6, 0)

Benefits

  • Graceful handling of version differences
  • Better debugging experience
  • Allows runtime symbol selection based on availability

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions