Render SwiftUI previews in Visual Studio Code through Apple’s Xcode 27 headless MCP server.
Requirements
macOS with Xcode 27 or newer
Visual Studio Code 1.100 or newer
A Swift file included in an .xcworkspace or .xcodeproj
Xcode renders previews in the project’s build context, including its scheme, destination, dependencies, resources, and compiler settings. Standalone .swift files are therefore not supported.
Setup
Open the folder containing your Swift source and Xcode project.
Run SwiftUI Previews: Select Xcode Installation.
Run SwiftUI Previews: Set Up and follow any instructions shown in Output.
Open a saved Swift file and run SwiftUI Previews: Open Preview.
Features
Tabs for multiple #Preview declarations
Xcode preview variants, localization, preview arguments, timelines, and canvas toggles
Scheme, run destination, project, and Xcode selection
Refresh on save, pinning, configurable toolbar position, zoom, and PNG export
Open an interactive preview in Xcode or run the app in Simulator
Limitations
Previews are not interactive inside Visual Studio Code. Apple’s headless RenderPreview API returns a rendered image rather than a live view or event session. Use Open Live Preview in Xcode to interact with the preview, or Run App in Simulator to interact with the complete app.
Standalone Swift files cannot be rendered because Xcode needs a project or workspace build context.
Preview controls are limited to the variants, arguments, timelines, and canvas toggles that Xcode exposes for the selected preview.