SwiftUI preview : PropertyListError: Property list missing value for required key "binaryType"

334 Views Asked by At

SwiftUI previews are not working in my project : when I try to display the preview in Xcode, I got this error :

enter image description here

And if I click on the help icon, here is the complete error message :

RemoteHumanReadableError: Invalid preview service message on ServiceHub channel

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

|  RemoteHumanReadableError
|  
|  PropertyListError: Property list missing value for required key ”binaryType”
|  Property list: ["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: Message send failure for <ServiceMessage 4: relaunch>

Is there anyone who already encountered this error message? Or maybe anyone who have any idea how to solve it?

Thanks,

Alexandre

1

There are 1 best solutions below

6
On BEST ANSWER

It seems like you're missing a particular simulator version. I faced this error before. I've installed two XCode versions: 14.3 and 15. And I made some examples for iOS 17 on XCode 15. Then, when I switched to the 14.3 with iOS 17 simulators, XCode would show up with that error even though I hadn't changed anything.

This image below is from XCode 14.3 with iOS 17.0 simulator.

enter image description here

Solution: Downgrade manually to lower Minimum Deployments, select lower simulator version 16.2, it works and the preview mode is rendered fine.

enter image description here

enter image description here