From what I've read online it wasn't available in the early Xcode 13 betas, but supposedly it's available in the current one. You might try upgrading Xcode 13 and see how you go.
If you need a version that works back to Xcode 11, macOS 10.11 and iOS 11, I wrote an alternate version with basically the same functionality. It's MIT and the code is available so you can go nuts with it! It should work with any project that supports Swift 5.1 (when propertyWrappers and static subscripts were introduced)
You can find it here
Post
Replies
Boosts
Views
Activity
Seeing the same thing here on macOS 12 (even with recent Xcode betas). The thumbnail seems to be completely ignored.
However, running the same application on macOS 13 beta (compiled with Xcode 14 beta 6) the custom thumbnail is appearing as expected (well, I've only tested for thumbnailData).
Annoying as hell. So much wasted time.
Btw I've tried this using Xcode 12, Xcode 13 beta, macOS 12 and macOS 13 beta. No luck with any combo
Okay I've re-tried this in Xcode 13 beta 6 and the problem appears to have fixed. Yay!
swift-driver version: 1.62.3 Apple Swift version 5.7 (swiftlang-5.7.0.123.8 clang-1400.0.29.50)
Target: x86_64-apple-macosx12.0
Thanks for the update mate. I have filed FB11490572 as you've mentioned.
Frustrating, but lets hope it can get some eyeballs on it.
I've been finding this with my own SPM packages, and reported by a number of users of that package. Filed bug FB11397938 back in August.
SettingsError: noExecutablePath(<IDESwiftPackageStaticLibraryProductBuildable:ObjectIdentifier(0x000060000d2b3b70):'QRCode'>)
Easily reproducible by adding a package to a blank SwiftUI project in Xcode 14. Cannot be reproduced in Xcode 13.
Still occurs on the Xcode 14 release [Version 14.0 (14A309)]. Booo!
Unfortunately, Xcode 14.1 beta (14B5024h) did not fix the issue for me. Still having the same issue.
Linking against a .dynamic type library fixes the SwiftUI preview breaking (well, at least for me) both on iOS and macOS
For example, linking against QRCodeDynamic (in my package.swift) :-
.library(
name: "QRCodeStatic",
type: .static,
targets: ["QRCode"]
),
.library(
name: "QRCodeDynamic",
type: .dynamic,
targets: ["QRCode"]
)
the SwiftUI previews start working correctly. Linking against a static library type always fails. At least this is a workaround if you're stuck.
This also works if the type is not specified.
.library(
name: "QRCode",
targets: ["QRCode"]
),
But not a fix.
Issue still occurs with Xcode Version 14.1 beta 2 (14B5024i).
Unfortunately, this is still an issue for me with 14.1 beta 3 [Xcode Version 14.1 beta 3 (14B5033e)]
HumanReadableSwiftError
SettingsError: noExecutablePath(<IDESwiftPackageStaticLibraryProductBuildable:ObjectIdentifier(0x0000600032e3b4e0):'DSFToolbar'>)
FB11513131 has been updated with a new preview report
sigh Still an issue in the Xcode 14.1 release. Exhausting.
I followed Microsoft's approach with my own libraries and removed the library type(s) from the Package.swift file and the issue 'goes away'. Hopefully this reduces the bug reports coming in stating that my library has 'broken' SwiftUI.
However, this is purely a workaround of the issue and not a solution. Some clients want to explicitly define their library usage and for them the Xcode bug persists.
If this is somehow my problem (ie. I'm using SPM incorrectly) then it would be awesome to understand how to fix it (especially since Xcode 13 didn't have this issue).
Xcode 14.2 appears to have resolved this issue for my apps - I'm being slightly optimistic on this version! Both my macOS and iOS targets now correctly show SwiftUI previews without erroring anymore.
Will keep testing...