Skip to content

SwiftUI previews breaks when adding a watchOS target #7610

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

Closed
antonbremer opened this issue Feb 25, 2021 · 9 comments
Closed

SwiftUI previews breaks when adding a watchOS target #7610

antonbremer opened this issue Feb 25, 2021 · 9 comments
Labels
beta-software Related to using beta iOS or Xcode versions. SwiftUI Issues directly related to Apple's SwiftUI framework watchOS

Comments

@antonbremer
Copy link

Step 0: Are you in the right place?

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 12.4 (12D4e)
  • Firebase SDK version: 7.7.0
  • Installation method: Swift Package Manager
  • Firebase Component: Analytics

[REQUIRED] Step 2: Describe the problem

After installing Firebase through SPM in a iOS project with a WatchOS target, SwiftUI previews do not work.
Xcode fails to build the scheme: "The package product 'GULAppDelegateSwizzler' requires minimum platform version 6.0 for the watchOS platform, but this target supports 2.0 (in target 'GoogleAppMeasurementTarget' from project 'GoogleAppMeasurement')"

Steps to reproduce:

  • Add the Firebase 7.7.0 SDK using Swift Package Manager to an iOS project that also has a WatchOS target
  • Generate a SwiftUI Preview on a Watch
  • Xcode fails to build the scheme. Diagnostics tell me: "The package product 'GULAppDelegateSwizzler' requires minimum platform version 6.0 for the watchOS platform, but this target supports 2.0 (in target 'GoogleAppMeasurementTarget' from project 'GoogleAppMeasurement')"

Only happens in SwiftUI preview mode, the project seems to build fine when running it in DEBUG mode.

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@ryanwilson
Copy link
Member

Hey @antonbremer - thanks for the report.

Unfortunately, Analytics isn't supported on watchOS yet. You can follow along the feature request (#4557) for updates. Due to the way SwiftPM works we can't specify individual platform support per product so we have to wrap it and exclude the binary altogether from the platform it doesn't support - looks like this isn't working for SwiftUI previews though. We'll see if we can come up with a better solution! I'll close the issue for now since it's known not to work but if there's anything else related please feel free to keep commenting. Thanks!

@antonbremer
Copy link
Author

antonbremer commented Feb 26, 2021

Hi @ryanwilson, thank you for your quick response!

For me personally I don't need Firebase Analytics to work on watchOS to be honest, but it's good to hear there is a feature request for it nevertheless.

Just some extra information for you guys on this:

  • I haven't targeted watchOS (so I haven't added the Firebase library to my frameworks on watchOS, it's only added to iOS targets)
  • The project builds fine, so the issue I reported above is purely about the SwiftUI previews for watchOS that aren't working with Swift Package Manager.
  • I checked other versions, and it does work fine on version 7.5.0
  • It looks like this issue was introduced on 7.6.0

One more question is: "since it's known not to work" < Is there a related issue that I can follow?

Thanks!

@ryanwilson
Copy link
Member

Thanks @antonbremer for the extra information! Apologies for the accidental diagnosis - I thought that you were trying to include Analytics on watchOS. I'll re-open this until we can track down the issue.

Side note: do you have code coverage enabled by any chance? It could be a similar bug to #6219 but manifested differently, we can investigate that.

One more question is: "since it's known not to work" < Is there a related issue that I can follow?

This was related to Analytics not working on watchOS, so it's not relevant anymore.

@ryanwilson ryanwilson reopened this Feb 26, 2021
@ryanwilson ryanwilson changed the title Platform version errors in a project with WatchOS targets SwiftUI previews breaks when adding a watchOS target Feb 26, 2021
@ryanwilson ryanwilson added the SwiftUI Issues directly related to Apple's SwiftUI framework label Feb 26, 2021
@ryanwilson
Copy link
Member

I renamed the title to try to encompass the true error, but please feel free to change it back if you prefer.

@ryanwilson
Copy link
Member

I was able to reproduce locally. This isn't just Analytics, it's any product. I could reproduce with just Database (which doesn't support watchOS at the moment).

It looks like SwiftUI previews is also trying to build any frameworks linked with the main app against the watchOS target. There may be some workarounds for source based products (making sure they're compiled out, or maybe SwiftUI previews honour @available checks) but binary products (Analytics) may be stuck.

It's likely worth filing a Feedback/Radar with Apple about this since the SwiftUI preview mechanism is doing something it shouldn't (as far as I'm aware). Maybe there's a need for it due to an implementation detail, but still an issue.

@antonbremer
Copy link
Author

Hi @ryanwilson. Thanks for researching and reproducing this.
If it's still worth something: I don't have code coverage enabled.
It looked like it worked fine in 7.5.0, but unfortunately after a few times it has the same problem as 7.7.0.

@BobbyRohweder
Copy link

It looks like the SwiftUI Previews build issue is fixed in Xcode 13 Beta 1

@ryanwilson ryanwilson added the beta-software Related to using beta iOS or Xcode versions. label Jul 22, 2021
@paulb777
Copy link
Member

I'm going to close, since there's nothing more to do here other than update to Xcode 13.

@firebase firebase locked and limited conversation to collaborators Sep 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
beta-software Related to using beta iOS or Xcode versions. SwiftUI Issues directly related to Apple's SwiftUI framework watchOS
Projects
None yet
Development

No branches or pull requests

5 participants