airbnb / lottie-ios

An iOS library to natively render After Effects vector animations
http://airbnb.io/lottie/
Apache License 2.0
25.7k stars 3.74k forks source link

Fix for watchOS preview build issue #2412

Closed sergeirr closed 4 months ago

sergeirr commented 4 months ago

For some reason Xcode watchOS SwiftUI preview attempts to build this package against watchOS SDK.

Fixed by adding canImport(QuartzCore) check to all files, it also might be replaced with !os(watchOS).

Tested with:

Additional info: https://developer.apple.com/forums/thread/731732

Here is an example project to reproduce the issue. You can try to build this package to "Any watchOS" target as well. CI check step also can be added to build this package to watchOS target.

calda commented 4 months ago

Hi @sergeirr, thank you for this detailed bug report and change. Since this is a workaround for a specific watchOS build bug, Lottie explicitly doesn't support watchOS, and this change introduces non-trivial overhead for future changes, I'd prefer we not merge this.

Does this issue only occur when integrating Lottie via SPM? Have you considered integrating Lottie another way, like by directly embedding the Lottie.xframework archive from the latest release? If another integration option doesn't have this issue I'd recommend using that option instead. Also, maintaining a forked repo with this change could be reasonable.