You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SwiftUI预览报错:PropertyListError缺失必填键'binaryType'

SwiftUI预览无法正常工作:缺失"binaryType"键报错

项目中SwiftUI预览功能失效,在Xcode中尝试显示预览时触发错误,完整错误信息如下:

RemoteHumanReadableError: ServiceHub通道上的预览服务消息无效

==================================

|  RemoteHumanReadableError
|  
|  PropertyListError: 属性列表缺少必填键"binaryType"
|  属性列表: ["agentRole": previews, "environment": {
|      "DYLD_FRAMEWORK_PATH" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator";
|      "DYLD_LIBRARY_PATH" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator";
|      "OS_ACTIVITY_DT_MODE" = YES;
|      "PACKAGE_RESOURCE_BUNDLE_URL" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphoneos";
|      "SQLITE_ENABLE_THREAD_ASSERTIONS" = 1;
|      "XCODE_RUNNING_FOR_PREVIEWS" = 1;
|      "__XCODE_BUILT_PRODUCTS_DIR_PATHS" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator";
|      "__XPC_DYLD_FRAMEWORK_PATH" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator";
|      "__XPC_DYLD_LIBRARY_PATH" = "/Users/alexandrecools/Library/Developer/Xcode/DerivedData/MyProject-gqsbendjcwgnvygdhqcoqqznoijh/Build/Intermediates.noindex/Previews/PreviewTesting/Products/Debug-iphonesimulator";
|  }, "__unique_service_message_identifier": 4, "deviceEnvironment": {
|      "SIMULATOR_CAPABILITIES" = "/Applications/Xcode 14.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/DeviceTypes/iPhone 14 Pro Max.simdevicetype/Contents/Resources/capabilities.plist";
|      "SIMULATOR_DEVICE_NAME" = iPhone4Simulator;
|      "SIMULATOR_LEGACY_ASSET_SUFFIX" = iphone;
|      "SIMULATOR_MAINSCREEN_HEIGHT" = 2796;
|      "SIMULATOR_MAINSCREEN_PITCH" = "460.000000";
|      "SIMULATOR_MAINSCREEN_SCALE" = "3.000000";
|      "SIMULATOR_MAINSCREEN_WIDTH" = 1290;
|      "SIMULATOR_MODEL_IDENTIFIER" = "iPhone15,3";
|      "SIMULATOR_PRODUCT_CLASS" = D74;
|  }, "agentIdentifier": {
|      bundleID = "com.apple.dt.XCPreviewAgent";
|      discriminant = bundleID;
|  }, "displaySize": {
|      height = 932;
|      width = 430;
|  }, "deviceIdentifier": com.apple.CoreSimulator.SimDeviceType.iPhone-14-Pro-Max, "processType": application, "arguments": <__NSArray0 0x1b9e04f48>(
|  
|  )
|  , "workspaceID": E4CEE565-58C6-4EB5-94F1-7A9F48791515, "deviceType": simulated, "payloadUsedAgentIdentifier": 1, "frameBufferMaskPath": /Applications/Xcode 14.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/DeviceTypes/iPhone 14 Pro Max.simdevicetype/Contents/Resources/framebuffer.pdf, "displayScale": 3, "bundleID": com.apple.dt.XCPreviewAgent]

==================================

|  MessageSendFailure: <ServiceMessage 4: relaunch>消息发送失败

解决思路

  • 清理Derived Data:打开Xcode,点击顶部菜单Xcode > 设置 > 位置,找到Derived Data对应的文件夹,删除当前项目的Derived Data目录,重启Xcode后重试预览。
  • 重置模拟器:打开模拟器,点击设备 > 抹掉所有内容和设置,重置完成后再尝试加载SwiftUI预览。
  • 检查项目构建设置:进入项目的Build Settings,确认Architectures设置为标准架构(arm64, x86_64),避免自定义架构导致的预览服务兼容性问题。
  • 升级Xcode:当前使用的是Xcode 14.1,尝试升级到最新稳定版本,新版本通常会修复预览服务的已知bug。
  • 重新配置预览目标:如果项目使用了自定义预览目标,尝试删除后重新创建,或者切换回默认的预览配置。

内容的提问来源于stack exchange,提问作者Alexandre Cools

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 00:33:30