【发布时间】:2021-03-03 04:44:22
【问题描述】:
我是 iOS 开发新手(做过 Flutter 和一些 react Native),我想开始制作 iOS 应用程序。
但是我在启动预览画布时遇到了问题。当我开始一个新项目时,构建在启动预览画布时完美完成,但加载一点后我收到此错误:“无法在 iPhone 11 Pro 上安装预览主机“IntervalTraining.app”:提供所需应用程序的有效路径捆绑”
我假设预览主机无法以某种方式找到应用程序,但奇怪的是,当我运行模拟器时,一切正常,并且应用程序安装在模拟器上..
我尝试过“清理构建文件夹”,但这不起作用。我试图擦除模拟器 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
【问题讨论】: