SwiftUI的预览画布无法工作,找不到应用程序捆绑包



我是iOS开发的新手(已经完成了flutter和一些本地react(,我想开始制作iOS应用程序。

然而,我在启动预览画布时遇到了问题。当我启动一个新项目时,在启动预览画布时构建完美完成,但在加载一点后,我得到了这个错误:";无法安装预览主机";IntervalTraining.app";在iPhone 11 Pro上:提供到所需应用程序捆绑包的有效路径";

我认为预览主机找不到应用程序,但奇怪的是,当我运行模拟器时,一切都很好,应用程序安装在模拟器上。。

我试着";清除构建文件夹";但这行不通。我试着删除模拟器iPhone上的所有数据,然后再次在模拟器上重新安装,然后运行预览画布,但这也不起作用。我还多次尝试删除DerivedData文件夹中的所有文件并创建新项目。我也试过用谷歌搜索这个问题,但我大多在苹果开发者论坛上找到我已经尝试过或不起作用的解决方案。我发现的大多数问题似乎也与本土反应有关。。。

其他人遇到过同样的问题吗?

编辑:我正在Catalina 10.15.6上运行XCode 12.2和一个全新的hello world项目:

import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello, world!")
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}

生成的报告如下:

FailedToInstallAppError: Failed to install "IntervalTraining.app"
Could not install the preview host "IntervalTraining.app" on iPhone 11 Pro
agentBundle = com.andreasjohansson.IntervalTraining {
url: file:///Users/andreas/Library/Developer/Xcode/DerivedData/IntervalTraining-awlguvqxylziguefdxawcmontfri/Build/Intermediates.noindex/Previews/IntervalTraining/Products/Debug-iphonesimulator/IntervalTraining.app
version: 8468
signingInformation: Code Signing {
identifier: com.andreasjohansson.IntervalTraining
hasGetTaskAllow: false
isSandboxed: false
}
}
udid = AD33D7B1-27B6-4028-BA10-CD2A289EB378
device = iPhone 11 Pro (AD33D7B1-27B6-4028-BA10-CD2A289EB378, iOS 14.2, Booted)
==================================
|  HumanReadableNSError: Failed to install the requested application
|  
|  Provide a valid path to the desired application bundle.
|  
|  NSPOSIXErrorDomain (2):
|  ==NSLocalizedFailureReason: An application bundle was not found at the provided path.
|  ==bundleURL: file:///Users/andreas/Library/Developer/Xcode/DerivedData/IntervalTraining-awlguvqxylziguefdxawcmontfri/Build/Intermediates.noindex/Previews/IntervalTraining/Products/Debug-iphonesimulator/IntervalTraining.app

我不知道这对你是否有帮助。

我从一位值得信赖的同事那里得到的一个项目中也出现了类似的错误。将BundleID更改为我的之后。我会得到";agentBundle=";问题

我打扫了——重建了。关闭&重新启动项目。最后,在关闭并重新启动XCode之后,它按预期工作。

不知道问题或解决方案在哪里。。。

最新更新