SwiftUI 预览显示错误 - 无法在此文件中预览 - 当前目标需要调整构建设置
SwiftUI Preview displays error - Cannot preview in this file -- current target needs adjusted build settings
我正在使用 Xcode 11.1,我的所有 swift 预览都显示以下错误:
Cannot preview in this file -- current target needs adjusted build settings
连同
"ProjectTests.xctest' failed to get build
settings:
unsupportedProductType("com.apple.product-type.bundle.unit-test", <Xc..."
单击诊断按钮会生成以下弹出窗口:
Open file has supported build settings
"ProjectTests.xctest" failed to get build settings: unsupportedProductType("com.apple.product-type.bundle.unit-test", <Xcode3TargetProduct:0xblahblahblahProjectTests.xctest blueprint:< Xcode3Target:0xblahblahProjectTests>>)
我的预览仍然可以正常渲染,但是有什么方法可以消除这个错误吗?
将目标更改为某些模拟器而不是 "iOS Generic Device" 或在预览提供程序中明确指定预览设备,例如
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.previewDevice("iPhone 11")
}
}
Xcode 版本 11.1 (11A1027)
Xcode 版本 11.2 (11B52) 中不再存在此错误。
我正在使用 Xcode 11.1,我的所有 swift 预览都显示以下错误:
Cannot preview in this file -- current target needs adjusted build settings
连同
"ProjectTests.xctest' failed to get build settings: unsupportedProductType("com.apple.product-type.bundle.unit-test", <Xc..."
单击诊断按钮会生成以下弹出窗口:
Open file has supported build settings "ProjectTests.xctest" failed to get build settings: unsupportedProductType("com.apple.product-type.bundle.unit-test", <Xcode3TargetProduct:0xblahblahblahProjectTests.xctest blueprint:< Xcode3Target:0xblahblahProjectTests>>)
我的预览仍然可以正常渲染,但是有什么方法可以消除这个错误吗?
将目标更改为某些模拟器而不是 "iOS Generic Device" 或在预览提供程序中明确指定预览设备,例如
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.previewDevice("iPhone 11")
}
}
Xcode 版本 11.1 (11A1027)
Xcode 版本 11.2 (11B52) 中不再存在此错误。