-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't compile for SwiftUI Previews #949
Conversation
… dynamic be the special case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dimitribouniol thanks a lot for tracking this down and clear explanation of the problem. I was able to reproduce it and indeed, this fixes the issue 👍.
I wasn't aware of other impacts, hence did some test in scenarios that we already patched Package.swift
for, notably:
- RUMM-392 SDK is set dynamic in SPM #82
- RUMM-1206 Make
DatadogCrashReporting
static inPackage.swift
#449 - Swift Package Manager - Add static library variants to allow use inside frameworks #405
Ideally, the Static and Dynamic variants should be removed or deprecated, but I'm unaware of a method of signaling that, so I added an appropriate todo to remove at least the static variant in the next major version.
This is my feeling too, however given that Xcode's SPM isn't yet perfect (see this swift.org thread), I'm not entirely sure if we can solely rely on Xcode and "automatic" linking (I remember this to be broken in previous versions of Xcode, but appears to be fixed now). As we plan changes in our modules layout, I linked appropriate tasks in TODOs to look into this closer.
Thanks for getting this in so quickly @ncreated! Do you know roughly when a version will be tagged with this change so we can switch to it? |
Hey @dimitribouniol - we plan on releasing |
Thanks for the update, looking forward to it! |
What and why?
This package is the only one that cannot be used if our own project uses SwiftUI Previews in our own packages (ie. Xcode Project links a single SPM package that links all our other dependencies, though I'd tried other arrangements unsuccessfully). This is because all library products in this package explicitly specify either
.static
or.dynamic
, which does not play well with Xcode's build system when it needs to wiggle things around for previews.Specifically, when importing the static variant, previews fail with:
and when it's dynamic:
This fails both in Xcode 13 and all Xcode 14 betas that I've tried.
How?
As packaging as a dynamic library is an optimization step for when users don't want to bloat their binary (which they could better accomplish by including their own wrapper product specific to their project), this reverts the unqualified products to not specify a library type which is the norm for the vast majority of projects, and introduces a new set of qualified types for the dynamic use case.
Ideally, the Static and Dynamic variants should be removed or deprecated, but I'm unaware of a method of signaling that, so I added an appropriate todo to remove at least the static variant in the next major version.
Review checklist
Custom CI job configuration (optional)