diff --git a/Demo App/Demo App/ContentView.swift b/Demo App/Demo App/ContentView.swift index d96dd6a..f01139e 100644 --- a/Demo App/Demo App/ContentView.swift +++ b/Demo App/Demo App/ContentView.swift @@ -27,16 +27,24 @@ struct ContentView: View { VStack { Label("Hello, World!", systemImage: Symbols.globe()) Spacer() - LazyVGrid(columns: .init(repeating: GridItem(.fixed(50)), count: 5), content: { - ForEach(Symbols.allCases, id: \.self.rawValue) { symbol in + LazyVGrid(columns: columns) { + ForEach(Symbols.allCases) { symbol in symbol.image .imageScale(.medium) .font(.largeTitle) } - }) + } } .padding() } + + private var columns: [GridItem] { + .init(repeating: GridItem(.fixed(50)), count: 5) + } +} + +extension Symbols: Identifiable { + var id: String { self.rawValue } } #Preview { diff --git a/Sources/SFSymbolsMacroImpl/SFSymbolsMacro.swift b/Sources/SFSymbolsMacroImpl/SFSymbolsMacro.swift index 0cb5e7b..e39a034 100644 --- a/Sources/SFSymbolsMacroImpl/SFSymbolsMacro.swift +++ b/Sources/SFSymbolsMacroImpl/SFSymbolsMacro.swift @@ -96,9 +96,11 @@ public struct SFSymbolMacro: MemberMacro { } private static func assertUINSImage(for id: (SymbolPair)) throws { - if let _ = NSImage(systemSymbolName: id.id, accessibilityDescription: nil) { - return - } + #if canImport(UIKit) + if let _ = UIImage(systemName: id.id) { return } + #else + if let _ = NSImage(systemSymbolName: id.id, accessibilityDescription: nil) { return } + #endif throw DiagnosticsError(diagnostics: [ .init(node: id.node, message: SFSymbolDiagnostic.noValidSFSymbol(symbol: id.0)) ])