SwiftUI - SF Symbols Do Not Render
Asked Answered
A

1

7

I'm trying to show a "plus" or "plus.app" sign via the SF Symbols in my code, but the preview to the right shows nothing.

Other symbols do work like "plus.circle", is there a reason why the other symbols aren't working?

Here is my view.

var body: some View {
    NavigationView {
        List(items) { item in
            Text(item.description)
        }
        .navigationBarTitle(Text("Grocery Items"))
        .navigationBarItems(leading:
            PresentationButton(
                Image(systemName: "plus")
                    .imageScale(.large)
                    .padding(),
                destination: ItemDetailView(item: items[0])
            )
        )
    }
}

I expect the output to show the "plus.app" or "plus" symbol, but it shows nothing when I use those symbols.

Application answered 9/6, 2019 at 7:1 Comment(0)
O
4

I had the same problem with the default preview device, as well as iPhone XS simulator.

Changing the preview device to "iPhone XR" solved the issue for me. It's probably a bug and will be fixed in the next releases.

You can change the preview device as below:

#if DEBUG
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
          .previewDevice(PreviewDevice(rawValue: "iPhone XR"))
    }
}
#endif

Update:

I tried the same with Xcode 11 beta 3 and it seems this issue was fixed.

Outbreed answered 9/6, 2019 at 7:39 Comment(3)
Even on the iPhone XR device, I cannot get the symbols to render as tabItemLabel views. They work fine in main content body views.Bauxite
@raffjones Is that fixed in beta 3?Outbreed
I don't know! In Xcode beta 3, tabItemLabel is deprecated, but when I change to the recommended tabItem, TabbedView throws an error now: "Cannot convert value of type 'Binding<Int>' to expected argument type 'Binding<_>'" so I can't get it to work at allBauxite

© 2022 - 2024 — McMap. All rights reserved.