SvenTiigi / WhatsNewKit

Showcase your awesome new app features 📱
https://sventiigi.github.io/WhatsNewKit/
MIT License
3.87k stars 190 forks source link

WhatsNewKit iOS dependency preventing SwiftUI preview for watchOS app #70

Closed john-work-ios closed 1 year ago

john-work-ios commented 1 year ago

What happened?

XCode 15 + iOS app (min target iOS 15) + watchOS app (min target watchOS 9). WhatsNewKit as SPM dependency for the iOS app.

Problem: when previewing SwiftUI views for the watch app, I get this error:

` == PREVIEW UPDATE ERROR:

SchemeBuildError: Failed to build the scheme ”MyAppWatch Watch App”

'SymbolRenderingMode' is only available in watchOS 8.0 or newer

Emitting module for WhatsNewKit:
/Users/user/Library/Developer/Xcode/DerivedData/MyApp-gglszqrqhbbrmqcgpkravwysjmar/SourcePackages/checkouts/WhatsNewKit/Sources/Models/WhatsNew+Feature+Image.swift:110:31: error: 'SymbolRenderingMode' is only available in watchOS 8.0 or newer
        symboldRenderingMode: SymbolRenderingMode?,`

What are the steps to reproduce?

-

What is the expected behavior?

Do not block SwiftUI previews

SvenTiigi commented 1 year ago

Hi @john-work-ios,

As the WhatsNewKit does not support the watchOS platform please update your Xcode project configuration to exclude WhatsNewKit from your watchOS App Target compilation process.

https://github.com/SvenTiigi/WhatsNewKit/blob/1366a8b5855ea97fc52439f68ff29b15846d9403/Package.swift#L5-L10

john-work-ios commented 1 year ago

That's just it, the watchOS target does not have WhatsNewKit in its dependencies. The issue only occurs with SwiftUI previews. Any clue?

shaundon commented 7 months ago

I'm also experiencing this issue, so I decided to investigate it further. It seems that it's an issue with Xcode previews (source: Apple Developer forums).

In SwiftUIIntrospect, they fixed it by adding a load of #if !os(watchos) statements to the code, but I appreciate that it's inconvenient to do that.

A workaround that I've verified is to make a new scheme that's just for previews. See this forum post for instructions.