Add basic watchOS support to better support multi platform apps #78
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.
This PR is mainly to prevent compile time errors and doesn’t implement a good UX on watchOS. I have a multiplatform app. With Xcode 15 I can't build my app anymore as Roadmap fails to compile for watchOS. I think in most cases a Roadmap doesn't make sense on watchOS. But I'm not aware of a good way to restrict platforms for a Swift package.
https://forums.swift.org/t/restrict-platforms-for-packages/29456/7
Not mentioning watchOS in platforms just means the oldest watchOS version is supported implicitly.
I'm not 100% sure yet why Xcode even tries to compile Roadmap for watchOS in my project. I only have it as a dependency in my own Package.swift for a library target that is only added to an iOS target. I also added a TargetDependencyCondition
.product(name: "Roadmap", package: "Roadmap", condition: .when(platforms: [.iOS])),
And the actual view is surrounded with#if os(iOS) #endif
But this iOS target also embeds my watchOS target.This PR only fixes the errors. I didn't make any other changes so the watchOS UX is probably not very good. I don't plan to use Roadmap on my watchOS app anyway. But this is how the preview looks.
Edit: I missed another dependency that was also depending on Roadmap. Adding
condition: .when(platforms: [.iOS]))
there as well fixed things. So now it's not building for watchOS anymore. Therefore I don't need these changes anymore. But maybe it's still useful for others to have this basic compatibility. Then you don't need to constrain everything.