First of all: I wrote this library a long time ago for the simple reason that it is reusable. I found it too time-consuming to keep rewriting it for different apps, so now you can always import it, which makes things a lot faster.
A lightweight SwiftUI library that provides consistent, scalable transport line symbols for iOS, macOS, watchOS, and Mac Catalyst.
Designed for apps that display public transport data such as S-Bahn, U-Bahn, Tram, Bus, Ferry, or regional trains.
In this example, we display a simple transport symbol, without any further customization. The example demonstrates how easy it is to use, simply by importing the TransportSymbols.
import SwiftUI
import TransportSymbols
struct ContentView: View {
var body: some View {
VStack {
SbahnSymbolView()
}
}
}It's very simple; with just a few lines of code, you can add the symbol.

In this example, we show how to display the symbols in a simple list with sample station names, simply by importing the TransportSymbols.
import SwiftUI
import TransportSymbols
struct ContentView: View {
var body: some View {
List {
stationRow(name: "Example", sbahn: true, ubahn: true, tram: true)
stationRow(name: "Test", sbahn: false, ubahn: true, tram: true)
stationRow(name: "Some Place", sbahn: false, ubahn: true, tram: false)
}
}
@ViewBuilder
func stationRow(name: String, sbahn: Bool, ubahn: Bool, tram: Bool) -> some View {
VStack(alignment: .leading, spacing: 3) {
Text(name)
.bold()
HStack {
if sbahn { SbahnSymbolView() }
if ubahn { UbahnSymbolView() }
if tram { TramSymbolView() }
}
}
}
}
#Preview {
ContentView()
}A bit broken down, but that's how you could do it.

You can also create your own symbols based on this pattern.
import SwiftUI
import TransportSymbols
struct ContentView: View {
var body: some View {
VStack {
TransportSymbolView(backgroundColor: .green) {
Image(systemName: "tram")
.imageScale(.small)
.foregroundStyle(.white)
}
}
}
}
#Preview {
ContentView()
}