devicekit / DeviceKit

DeviceKit is a value-type replacement of UIDevice.
MIT License
4.4k stars 425 forks source link

Import UIKit and WatchKit conditionally to work around Xcode Previews not working on Mac #352

Closed DenTelezhkin closed 5 months ago

DenTelezhkin commented 1 year ago

This PR is practically identical to https://github.com/devicekit/DeviceKit/pull/342 and solves the same issue - when DeviceKit is used as framework dependency, Mac targets importing that framework fail to build for Xcode Previews.

This is not a build issue in Debug / Release configuration, it is only reproducible with Xcode Previews, as Xcode Previews seem to not be understanding platform filters (Link binary with libraries / Filters -> iOS, platformFilter = ios).

The only difference of this PR from #342 is that instead of if os() conditionals this PR uses #if canImport() statements, which should be more resilient, however it's obviously up to maintainers to select which approach is better suited for DeviceKit.

la-pieuvre commented 8 months ago

thanks for your work, i hope someone will review it shortly :) (@denisenepraunig maybe)

Zandor300 commented 5 months ago

This issue should be fixed in v5.2.2 @la-pieuvre