When you create a new Xcode project in Xcode 13.2.1, you may face an error "Cannot preview in this file - Unexpected error occurred" or other similar error messages in the iOS swiftUI simulator preview feature. To resolve the error, try the following:



  1. Clicking on the "Diagnostics" button on the failed preview pane;
  2. Copy the ".pcm" file path. It looks like something similar to "/var/folders/aa/xxxxxxxxxxxxxxxxxxxxxxx/C/clang/ModuleCache/12345ABCDE/MyTest-XXXXXXXXXXXXXX.pcm"
  3. Run the following command to remove the .pcm file in the Terminal app (replace the path using the specific path you copied from the Diagnostics log obtained in the step above:
rm -rf /var/folders/aa/xxxxxxxxxxxxxxxxxxxxxxx/C/clang/ModuleCache/12345ABCDE/MyTest-XXXXXXXXXXXXXX.pcm



Reference: https://developer.apple.com/forums/thread/696908



If you have any additional questions please contact our HelpDesk Support staff. To review our Cloud Mac service offerings, please visit our website MacinCloud.com.