Reputation: 23
canvas preview has an error just like that:
UnknownPreviewProviderError: Unknown preview provider "AboutView_Previews" 买就返.app does not contain a preview provider named "AboutView_Previews". Check your build settings to ensure the preview provider is compiled into your product. Mangled name: 3买就返18AboutView_PreviewsV
Error Domain=com.apple.dt.UITestingAgent Code=-1 "Preview provider "3买就返18AboutView_PreviewsV" does not exist" UserInfo={NSLocalizedDescription=Preview provider "3买就返18AboutView_PreviewsV" does not exist}
ihave check the "build setting" -> "build options" -> "Enable Previews" is Yes
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
HomeView()
.tabItem {
Image("tabbarHome")
Text("首页")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Upvotes: 2
Views: 2066
Reputation: 79
There was a similar error when the project name started with a digit (for example, 30-project-name). I just renamed the project with a name without numbers at the beginning
Upvotes: 1
Reputation: 508
I have the same issue when I modify the Product Name(at Target -> Packing -> Product Name) to Chinese word.
The right way to use Chinese word as App name:
Use this way to change app name will not effect SwiftUI Previews.
Upvotes: 2