XCode 13默认SwiftUi文件拒绝启动预览

发布于 2025-02-07 05:15:34 字数 1678 浏览 2 评论 0原文

我刚刚创建了一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文