krzysztofzablocki / Inject

Hot Reloading for Swift applications!
MIT License
2.14k stars 114 forks source link

Add @available(watchOSApplicationExtension 6.0, *) to all Inject classes to allow using it in a library that targets WatchOS as well #22

Closed tkafka closed 6 months ago

tkafka commented 2 years ago

(Obligatory intro - Inject is awesome, thank you!)

Hello, I develop an app that shares view code amon iOS and WatchOS extension targetys in a library. The library has set WatchOS 7.0 as a minimum target (see below), but adding Inject a dependency produces a lot of errors with SwiftUI APIs not available before WatchOS 6.

Could you please mark the classes (or a whole package - I don't know if it's possible) as WatcOS 6.0+ only?

Something like @available(watchOSApplicationExtension 6.0, *) should help.

Or is there a better way? I am confused as for why does Xcode try to build the package for all WatchOS versions if it's only going to be used in a library that targets 7.0+?

Thank you! Tomas

Screenshot 2022-04-13 at 11 26 58

Error Group
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Inject.swift:18:42: 'Animation' is only available in watchOS 6.0 or newer
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Inject.swift:45:30: 'AnyCancellable' is only available in watchOS 6.0 or newer
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Inject.swift:43:33: 'ObservableObject' is only available in watchOS 6.0 or newer
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/Hosts.swift:3:45: cannot find type 'UIViewController' in scope
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/Hosts.swift:4:35: cannot find type 'UIView' in scope
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/Hosts.swift:41:24: method does not override any method from its superclass
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/KitFrameworks.swift:5:11: cannot find type 'UIView' in scope
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/KitFrameworks.swift:6:11: cannot find type 'UIViewController' in scope
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/SwiftUI.swift:6:44: 'View' is only available in watchOS 6.0 or newer
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/SwiftUI.swift:14:74: 'View' is only available in watchOS 6.0 or newer
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/SwiftUI.swift:5:26: 'View' is only available in watchOS 6.0 or newer
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/SwiftUI.swift:6:31: 'some' return types are only available in watchOS 6.0.0 or newer
<redacted path>/SourcePackages/checkouts/Inject/Sources/Inject/Integrations/SwiftUI.swift:14:61: 'some' return types are only available in watchOS 6.0.0 or newer
tkafka commented 2 years ago

Or, maybe just add .watchOS(.v6)into supported platforms? I'll try this.

tkafka commented 2 years ago

This seems it might work, but I have been unable to get the shared library to work with Inject because of other problems. Would you try adding it? I created a PR: https://github.com/krzysztofzablocki/Inject/pull/23