XCode 13默认SwiftUi文件拒绝启动预览
我刚刚创建了一个SwiftUi视图文件,它拒绝渲染预览。我没有将任何内容更改为默认文件,以下是内容作为证明:
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello, World!")
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
当我尝试开始预览时,我会收到此错误: 无法在此文件中预览 - 消息发送失败以发送预告键消息到代理
然后单击诊断
显示以下内容:
MessageSendFailure: Message send failure for send previewInstances message to agent
==================================
| RemoteHumanReadableError
|
| LoadingError: failed to load library at path "/Users/ambrosine/Library/Containers/C62869A9-4B70-4E37-8214-47A4E1A1AB38/Data/ContentView.1.preview-thunk.dylib": Optional(dlopen(/Users/ambrosine/Library/Containers/C62869A9-4B70-4E37-8214-47A4E1A1AB38/Data/ContentView.1.preview-thunk.dylib, 0x0002): tried: '/Users/ambrosine/Library/Developer/Xcode/DerivedData/Layer_Cake-arsciremknllubbhasphthxgplvu/Build/Intermediates.noindex/Previews/Layer Cake (macOS)/Products/Debug/ContentView.1.preview-thunk.dylib' (no such file), '/Users/ambrosine/Library/Containers/C62869A9-4B70-4E37-8214-47A4E1A1AB38/Data/ContentView.1.preview-thunk.dylib' (code signature in <B85C00C0-8585-36D2-A859-1B19877BB41F> '/Users/ambrosine/Library/Containers/C62869A9-4B70-4E37-8214-47A4E1A1AB38/Data/ContentView.1.preview-thunk.dylib' not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)))
相当新,我真的不了解错误,似乎与代码签名有关,但我不完全确定如何解决该问题。
我还应该提到,该应用程序可以构建和工作,没有任何错误,并且我尝试清洁构建文件夹,重新启动Xcode并重新启动Mac。
I have just created a SwiftUI view file, and it is refusing to render previews. I have not changed anything to the default file, here are the contents as proof :
import SwiftUI
struct ContentView: View {
var body: some View {
Text("Hello, World!")
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
And when I try to start previews, I get this error :Cannot preview in this file -- Message send failure for send previewInstances message to agent
and clicking diagnostics
shows this :
MessageSendFailure: Message send failure for send previewInstances message to agent
==================================
| RemoteHumanReadableError
|
| LoadingError: failed to load library at path "/Users/ambrosine/Library/Containers/C62869A9-4B70-4E37-8214-47A4E1A1AB38/Data/ContentView.1.preview-thunk.dylib": Optional(dlopen(/Users/ambrosine/Library/Containers/C62869A9-4B70-4E37-8214-47A4E1A1AB38/Data/ContentView.1.preview-thunk.dylib, 0x0002): tried: '/Users/ambrosine/Library/Developer/Xcode/DerivedData/Layer_Cake-arsciremknllubbhasphthxgplvu/Build/Intermediates.noindex/Previews/Layer Cake (macOS)/Products/Debug/ContentView.1.preview-thunk.dylib' (no such file), '/Users/ambrosine/Library/Containers/C62869A9-4B70-4E37-8214-47A4E1A1AB38/Data/ContentView.1.preview-thunk.dylib' (code signature in <B85C00C0-8585-36D2-A859-1B19877BB41F> '/Users/ambrosine/Library/Containers/C62869A9-4B70-4E37-8214-47A4E1A1AB38/Data/ContentView.1.preview-thunk.dylib' not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)))
Being fairly new I don't really understand the error, seems to have something to do with code signing but I'm not entirely sure what and how to fix it.
I should also mentioned that the app builds and works without any errors, and that I have tried cleaning the build folder, restarting XCode, and restarting my Mac.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论