[英]xcode can't preview new SwiftUI project
I'm running Catalina 10.15.7, and XCode 12.3.我正在运行 Catalina 10.15.7 和 XCode 12.3。
New Project -> Single View App -> provide name (all alpha, no breaks or punctuation).新项目 -> 单一视图应用程序 -> 提供名称(所有字母,无中断或标点符号)。 Project launches.
项目启动。 Without making any changes whatever, I click on Resume Preview, and get a message: "Cannot preview in this file: Failed to launch
不做任何更改,我点击恢复预览,并收到一条消息:“无法在此文件中预览:启动失败
The code in ContentView.swift is standard, and confirmed in various videos etc.: ContentView.swift 中的代码是标准的,并在各种视频等中确认:
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello, world!")
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
As I launched XCode, I was asked to upgrade certain unspecified components, which I did.当我启动 XCode 时,我被要求升级某些未指定的组件,我照做了。
But no joy.但没有喜悦。 What's the solution?
解决方案是什么?
The answer was obviousish once found, which of course happened right after asking.一旦找到答案就很明显了,这当然是在询问之后发生的。
I had mistakenly created a project for macos, and I wanted a project for iOS.我错误地为macos创建了一个项目,我想要一个iOS的项目。 I'm pretty sure that most of you figured that out...
我敢肯定,你们中的大多数人都明白这一点...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.