Remove explicitly typed package products #48
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Related issues
Didn't create an issue up-front as it seemed like more work than just contributing a PR :)
Describe the solution you've provided
As of Xcode 14 beta 5 (have not tested earlier betas, it works on 13.4.1), adding the LaunchDarkly SDK to a project breaks SwiftUI previews. The error you get is fairly non-descriptive but strongly hints to an issue finding an executable (?) for the
LDSwiftEventSourceStatic
product:Looking at the Package.swift file for LaunchDarkly I noticed that it's referencing the explicitly static typed target for the event source package. Changing this to a target without explicit package type solves the issue. This is trivially reproducible using Xcode 14b5:
I'm not sure why this package declares both types explicitly, as this isn't the recommended approach when a package supports both static and dynamic linking as noted by SPM documentation (note the
type
parameter docs). I'm sure there's a reason though, so in order to limit breaking changes this PR renames the currentLDSwiftEventSource
product toLDSwiftEventSourceDynamic
and introduces a newLDSwiftEventSource
without an explicit product type. Doing this and changing the LaunchDarkly package to reference this new target instead of the static one, the project created above renders previews successfully. The downside is that any library consumers relying on the fact thatLDSwiftEventSource
is of dynamic type now might see build/linkage failures.Describe alternatives you've considered
None, as I'm not sure what other solutions might exist.
Additional context
None.