“无法在此文件中预览-无法启动[应用名称]" [英] "Cannot Preview in this file - Failed to launch [App Name]"

查看:85
本文介绍了“无法在此文件中预览-无法启动[应用名称]"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Xcode 11和macOS Catalina中使用swiftUI.但创建一个新项目后,有一个带有文本的样板代码,该文本说"hello World".我想在代码旁边的画布中实时预览此简单的欢迎消息.

I am trying to play around with swiftUI in Xcode 11 and macOS Catalina. BUT After creating a new Project, there is a boiler plate code with a Text that says hello World. I want to have a live preview of this simple welcome message in the canvas by the side of the code.

当我按下恢复"按钮时:它说:

When i hit the resume button : It says :

无法在此文件中预览-无法启动[应用名称]

Cannot Preview in this file - Failed to launch [App Name]

我尝试点击诊断按钮以生成报告,并将其发送给APPLE,说:

I've tried hitting the diagnostic button that generated a report to send it to APPLE saying:

[FailedToLaunchError(url:文件:///Users/naive/Library/Developer/Xcode/DerivedData/first_swiftUI-dymizjogcbtouhclgjhhefagmcqo/Build/Intermediates.noindex/Previews/first_swiftUI/Products/Debug-iphoneos/first_swiftUI.app,底层:错误域= NSOSStatusErrorDomain代码= -10661(空)"UserInfo = {_ LSLine = 3554,_LSFunction = _LSOpenStuffCallLocal},failureCategory:UVFoundation.FailureCategory.infrastructureFailure)]

[FailedToLaunchError(url: file:///Users/naive/Library/Developer/Xcode/DerivedData/first_swiftUI-dymizjogcbtouhclgjhhefagmcqo/Build/Intermediates.noindex/Previews/first_swiftUI/Products/Debug-iphoneos/first_swiftUI.app, underlying: Error Domain=NSOSStatusErrorDomain Code=-10661 "(null)" UserInfo={_LSLine=3554, _LSFunction=_LSOpenStuffCallLocal}, failureCategory: UVFoundation.FailureCategory.infrastructureFailure) ]

这是代码,这是通过Xcode 11和SwiftUI选项选中创建的新项目随附的默认代码:

Here's the code, It is the default code that comes with new project created with Xcode 11 and SwiftUI option checked:

import SwiftUI

struct ContentView : View {
    var body: some View {
        Text("Hello World")
    }
}

#if DEBUG
struct ContentView_Previews : PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
#endif

我希望画布出现并显示我的代码的实时预览.画布没有显示出来!

I expect the canvas to show up and display live preview of my code. The canvas is not showing up !!

生成了两个警告消息:

:0:警告:导入的声明'UITableViewDiffableDataSourceCellProvider'无法映射到'UITableViewDiffableDataSourceReference.CellProvider'

:0: warning: imported declaration 'UITableViewDiffableDataSourceCellProvider' could not be mapped to 'UITableViewDiffableDataSourceReference.CellProvider'

:0:警告:导入的声明无法映射"UICollectionViewDiffableDataSourceCellProvider"到'UICollectionViewDiffableDataSourceReference.CellProvider'

:0: warning: imported declaration 'UICollectionViewDiffableDataSourceCellProvider' could not be mapped to 'UICollectionViewDiffableDataSourceReference.CellProvider'

除此之外,我的带有iPadOS Beta的iPad 11"可以运行该应用程序,模拟器也可以正常工作

other than that, My iPad 11"with iPadOS beta runs the app, The simulator is working as well

推荐答案

使用SwiftUI启动iOS应用,然后在项目属性中检查Mac目标时,我遇到了此 UVFoundation.FailureCategory.infrastructureFailure .即使用Catalyst创建跨平台应用).当我这样做时,默认设备更改为我的Mac",并且预览停止工作,从而在诊断窗口中产生此错误.

I encountered this UVFoundation.FailureCategory.infrastructureFailure when starting an iOS app with SwiftUI and then checking the Mac target in the project properties (i.e., using Catalyst to create a cross-platform app). When I did this the default device changed to "My Mac" and preview stopped working, yielding this error in the diagnostic window.

似乎不支持Mac目标的预览-您必须选择一些iOS目标(通用iOS设备"对我来说很好用).在Mojave beta 5和Xcode 11 beta 5上进行了测试.从Xcode 11 beta 5发行说明中:"Xcode 11不支持在Mac Catalyst应用程序中使用SwiftUI.(41416222,51201699)"

Preview for the Mac target doesn't seem to be supported—you have to select some iOS target ("Generic iOS Device" works just fine for me). Tested on Mojave beta 5 with Xcode 11 beta 5. From the Xcode 11 beta 5 release notes: "Xcode 11 doesn’t support working with SwiftUI in a Mac Catalyst app. (41416222, 51201699)"

选择了我的Mac",它不起作用!

"My Mac" selected, it doesn't work!

使用通用iOS设备"已选择.

Working with "Generic iOS device" selected.

这篇关于“无法在此文件中预览-无法启动[应用名称]"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆