It's true that it's not possible to make a Preview in Objective-C, you will need a Swift file to house the preview. But, when used in conjunction with pinning you don't need to switch back and forth between the Swift and the Objective-C.
Here's what I did:
Made a new view controller in Objective-C
Imported the Objective-C view controller's header in my app's bridging header
In a Swift file, made a #Preview that instantiated the view controller
Clicked the "Pin" button in the upper left of the preview canvas
Went back to the Objective-C file: the preview stays up
Edited the Objective-C code. Hit Command-S to trigger the preview to update (it will happen on auto-save too, but that might not be as immediate as you want)
Post
Replies
Boosts
Views
Activity
I'm pretty sure this is a known issue, but the best thing for us would be to file a Feedback request with a previews diagnostics file.
The most helpful thing is to download and install the logging profile for your Mac/device. Instructions and profiles are available here: https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift
Attach the sysdiagnose to the radar as well as the diagnostics using the instructions below.
Then when you reproduce the problem in Xcode:
When the error banner appears, click the "Diagnostics" button in that banner.
In the sheet that appears, click "Generate Report" in the bottom left of the sheet
Attach (or make from the folder) the resulting zip file to the bug (will be named something like previews-diagnostics-0123456789.zip)
We're sorry you're having trouble using previews! We will need the diagnostics Xcode Previews generates in order to make sure we understand the error the previews system is encountering.
If you are having issues with Xcode, macOS, catalyst or on-device iOS previews then download and install the logging profile for your device. Instructions and profiles are available here: https://developer.apple.com/bug-reporting/profiles-and-logs/?name=swift
Attach the sysdiagnose to the radar as well as the diagnostics using the instructions below.
Then when you reproduce the problem in Xcode:
Either (a) an error banner will appear, click the "Diagnostics" button in that banner. Or (b) if you’re not seeing an error but you still want to provide diagnostics, you can get the same diagnostics window by going under the Editor menu in the menu bar, then selecting the Canvas submenu, then selecting “Diagnostics”.
In the sheet that appears, click "Generate Report" in the bottom left of the sheet
Attach (or make from the folder) the resulting zip file to the bug (will be named something like previews-diagnostics-0123456789.zip)