SwiftUI Previews or #Playground can fail with “Swift overlay library could not be found” even when the normal app build succeeds. Apple lists this Previews issue as fixed in Xcode 27.
Representative error
Preview failed
Swift overlay library could not be found.
The diagnostics may include additional details from the preview build and Swift compiler.
Cause
The message means that the Preview or #Playground build environment could not resolve the Swift overlay library for its selected SDK. Apple’s Xcode 27 release notes mark the issue as fixed under 179652645 (FB23154922). The public note does not enumerate every affected beta or release-candidate build, nor every configuration that could produce a similar message.
If Run or Archive fails with the same message, do not assume it is only the Previews bug. Check the selected Xcode, SDK, Swift packages, and binary dependencies as a broader toolchain problem.
Affected configurations
- SwiftUI Previews or
#Playgroundis being evaluated. - The project may be running an Xcode version before 27 or a prerelease Xcode 27 build from before the fix.
- A multi-Xcode, CI, or custom-toolchain setup may point the Developer Directory at a different Xcode than expected.
Xcode 27 is the officially documented fixed release. Determine whether a specific failure is the same issue by comparing the normal build and retesting after the update.
Recommended resolution
1. Update to Xcode 27 or newer
Open the project with a current production Xcode. If multiple copies are installed, verify the command-line selection as well.
xcodebuild -version
xcode-select -p
xcrun --find swiftc
If necessary, select the intended production Xcode:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
2. Compare a normal build with the Preview
Use Product > Build or Run with the same scheme and destination. If that succeeds while the Canvas alone fails, the evidence points more strongly to the Preview pipeline.
3. Recreate Preview build products after updating
Quit and reopen Xcode, then use Product > Clean Build Folder before restarting the Preview. This is a diagnostic step to exclude products created by the previous toolchain; Apple does not document it as a guaranteed permanent workaround.
4. Re-resolve Swift packages
For package-based projects, try File > Packages > Reset Package Caches, followed by Resolve Package Versions. If the normal build also fails, confirm that the problematic dependency supports the selected SDK and architecture.
Alternatives
If Xcode cannot be updated immediately, temporarily test the view in Simulator or on a physical device instead of using the Canvas. You can also move the view into a small project without external packages or custom build settings to isolate the trigger. These are diagnostic alternatives, not permanent substitutes for the fixed Xcode release.
How to verify the fix
xcodebuild -versionreports Xcode 27 or newer.xcode-select -ppoints to that Xcode’s Developer directory.- The normal Build or Run action succeeds.
- The Canvas renders the Preview without the overlay-library error.
Cautions
- Do not change the deployment target blindly before checking Xcode and Developer Directory selection.
- Repeatedly deleting DerivedData is not a confirmed fix by itself.
- If the error persists on Xcode 27 or newer, save the diagnostics and submit a minimal reproducer through Feedback Assistant.
Summary
When “Swift overlay library could not be found” affects only Previews or #Playground, it may be the issue Apple fixed in Xcode 27. Update to Xcode 27 or newer, verify the active Developer Directory, compare a normal build, and then retry the Preview.
Official references
- Xcode 27 Release Notes (checked September 18, 2026; 179652645 / FB23154922)
- Apple: Diagnosing issues using crash reports and device logs
