From c912210846faa2044167c4f5306bd5296c155c32 Mon Sep 17 00:00:00 2001 From: Alex Marchant Date: Thu, 20 Jan 2022 21:22:18 +0100 Subject: [PATCH 1/4] Add '#if arch(x86_64) || arch(arm64)' and @available() checks for projects targetting lower versions --- Sources/SkeletonUI/Angle/AngleInteractor.swift | 7 ++++++- Sources/SkeletonUI/Angle/AnglePresenter.swift | 5 +++++ Sources/SkeletonUI/Animation/AnimationInteractor.swift | 7 +++++++ .../SkeletonUI/Appearance/AppearanceInteractor.swift | 10 +++++++++- .../SkeletonUI/Appearance/AppearancePresenter.swift | 5 +++++ .../SkeletonUI/Extensions/ClosedRange+Normalize.swift | 6 +++++- Sources/SkeletonUI/Extensions/Image+OptionalType.swift | 5 +++++ .../Extensions/ModifiedContent+SkeletonModifier.swift | 4 ++++ .../SkeletonUI/Extensions/Optional+OptionalType.swift | 5 +++++ .../Extensions/SecureField+OptionalType.swift | 5 +++++ Sources/SkeletonUI/Extensions/Text+OptionalType.swift | 5 +++++ .../SkeletonUI/Extensions/TextField+OptionalType.swift | 5 +++++ .../SkeletonUI/Extensions/Toggle+OptionalType.swift | 6 ++++++ Sources/SkeletonUI/Extensions/UnitPoint+Angle.swift | 5 +++++ .../SkeletonUI/Extensions/View+SkeletonModifier.swift | 4 ++++ Sources/SkeletonUI/Modifiers/SkeletonModifier.swift | 4 ++++ Sources/SkeletonUI/Multiline/MultilineInteractor.swift | 6 ++++++ Sources/SkeletonUI/Multiline/MultilinePresenter.swift | 5 +++++ Sources/SkeletonUI/Opacity/OpacityInteractor.swift | 6 ++++++ Sources/SkeletonUI/Opacity/OpacityPresenter.swift | 5 +++++ Sources/SkeletonUI/Position/PositionInteractor.swift | 6 ++++++ Sources/SkeletonUI/Position/PositionPresenter.swift | 5 +++++ Sources/SkeletonUI/Protocols/OptionalType.swift | 5 +++++ Sources/SkeletonUI/Radius/RadiusInteractor.swift | 5 +++++ Sources/SkeletonUI/Radius/RadiusPresenter.swift | 5 +++++ Sources/SkeletonUI/Shape/ShapeInteractor.swift | 9 ++++++++- Sources/SkeletonUI/Shape/ShapePresenter.swift | 5 +++++ Sources/SkeletonUI/Skeleton/SkeletonForEach.swift | 4 ++++ Sources/SkeletonUI/Skeleton/SkeletonInteractor.swift | 7 ++++++- Sources/SkeletonUI/Skeleton/SkeletonList.swift | 4 ++++ Sources/SkeletonUI/Skeleton/SkeletonPresenter.swift | 5 +++++ Sources/SkeletonUI/Skeleton/SkeletonShape.swift | 5 +++++ Sources/SkeletonUI/Skeleton/SkeletonView.swift | 5 +++++ 33 files changed, 175 insertions(+), 5 deletions(-) diff --git a/Sources/SkeletonUI/Angle/AngleInteractor.swift b/Sources/SkeletonUI/Angle/AngleInteractor.swift index 2220dc1..93bf5e4 100644 --- a/Sources/SkeletonUI/Angle/AngleInteractor.swift +++ b/Sources/SkeletonUI/Angle/AngleInteractor.swift @@ -1,7 +1,9 @@ +#if arch(x86_64) || arch(arm64) + import Combine import SwiftUI -// sourcery: AutoMockable +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) protocol AngleInteractable: AnyObject { var presenter: AnglePresenter { get } var animation: CurrentValueSubject { get } @@ -9,6 +11,7 @@ protocol AngleInteractable: AnyObject { var range: CurrentValueSubject, Never> { get } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class AngleInteractor: AngleInteractable { let presenter = AnglePresenter() let animation: CurrentValueSubject @@ -27,3 +30,5 @@ final class AngleInteractor: AngleInteractable { range.map { $0.lowerBound }.assign(to: \.value, on: presenter).store(in: &cancellables) } } + +#endif diff --git a/Sources/SkeletonUI/Angle/AnglePresenter.swift b/Sources/SkeletonUI/Angle/AnglePresenter.swift index c9ec95a..b90ae08 100644 --- a/Sources/SkeletonUI/Angle/AnglePresenter.swift +++ b/Sources/SkeletonUI/Angle/AnglePresenter.swift @@ -1,7 +1,12 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class AnglePresenter: ObservableObject { @Published var animation: Animation? @Published var value: Double = .zero @Published var range: ClosedRange = .zero ... 360 } + +#endif diff --git a/Sources/SkeletonUI/Animation/AnimationInteractor.swift b/Sources/SkeletonUI/Animation/AnimationInteractor.swift index 15b7565..8cd8278 100644 --- a/Sources/SkeletonUI/Animation/AnimationInteractor.swift +++ b/Sources/SkeletonUI/Animation/AnimationInteractor.swift @@ -1,6 +1,9 @@ +#if arch(x86_64) || arch(arm64) + import Combine import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public enum AnimationType: Equatable { case none case pulse(range: ClosedRange = .zero ... 1, duration: Double = 2, delay: Double = 1, speed: Double = 2, autoreverses: Bool = true) @@ -8,6 +11,7 @@ public enum AnimationType: Equatable { } // sourcery: AutoMockable +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) protocol AnimationInteractable: AnyObject { var position: PositionInteractable { get } var opacity: OpacityInteractable { get } @@ -16,6 +20,7 @@ protocol AnimationInteractable: AnyObject { var type: CurrentValueSubject { get } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class AnimationInteractor: AnimationInteractable { let position: PositionInteractable let opacity: OpacityInteractable @@ -54,3 +59,5 @@ final class AnimationInteractor: AnimationInteractable { }.store(in: &cancellables) } } + +#endif diff --git a/Sources/SkeletonUI/Appearance/AppearanceInteractor.swift b/Sources/SkeletonUI/Appearance/AppearanceInteractor.swift index 69eb911..87d1416 100644 --- a/Sources/SkeletonUI/Appearance/AppearanceInteractor.swift +++ b/Sources/SkeletonUI/Appearance/AppearanceInteractor.swift @@ -1,12 +1,16 @@ +#if arch(x86_64) || arch(arm64) + import Combine import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public enum GradientType: Equatable { case linear case angular case radial } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public struct SkeletonColor { public static var primary: Color { #if os(iOS) @@ -33,18 +37,20 @@ public struct SkeletonColor { } } - +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public enum AppearanceType: Equatable { case solid(color: Color = SkeletonColor.primary, background: Color = SkeletonColor.background) case gradient(GradientType = .linear, color: Color = SkeletonColor.primary, background: Color = SkeletonColor.background, radius: CGFloat = 1, angle: CGFloat = .zero) } // sourcery: AutoMockable +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) protocol AppearanceInteractable: AnyObject { var presenter: AppearancePresenter { get } var type: CurrentValueSubject { get } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class AppearanceInteractor: AppearanceInteractable { let presenter = AppearancePresenter() let type: CurrentValueSubject @@ -56,3 +62,5 @@ final class AppearanceInteractor: AppearanceInteractable { type.assign(to: \.type, on: presenter).store(in: &cancellables) } } + +#endif diff --git a/Sources/SkeletonUI/Appearance/AppearancePresenter.swift b/Sources/SkeletonUI/Appearance/AppearancePresenter.swift index 1ba6199..f935afa 100644 --- a/Sources/SkeletonUI/Appearance/AppearancePresenter.swift +++ b/Sources/SkeletonUI/Appearance/AppearancePresenter.swift @@ -1,5 +1,10 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class AppearancePresenter: ObservableObject { @Published var type: AppearanceType = .gradient() } + +#endif diff --git a/Sources/SkeletonUI/Extensions/ClosedRange+Normalize.swift b/Sources/SkeletonUI/Extensions/ClosedRange+Normalize.swift index 260815b..c8f890f 100644 --- a/Sources/SkeletonUI/Extensions/ClosedRange+Normalize.swift +++ b/Sources/SkeletonUI/Extensions/ClosedRange+Normalize.swift @@ -1,5 +1,6 @@ -import CoreGraphics +#if arch(x86_64) || arch(arm64) +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension ClosedRange where Bound == CGFloat { func normalize(with range: ClosedRange) -> ClosedRange { let lowerBound = range.lowerBound == .zero ? self.lowerBound : range.lowerBound @@ -8,9 +9,12 @@ extension ClosedRange where Bound == CGFloat { } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension ClosedRange where Bound == Double { func normalize(with range: ClosedRange) -> ClosedRange { let normalized = (CGFloat(lowerBound) ... CGFloat(upperBound)).normalize(with: range) return Double(normalized.lowerBound) ... Double(normalized.upperBound) } } + +#endif diff --git a/Sources/SkeletonUI/Extensions/Image+OptionalType.swift b/Sources/SkeletonUI/Extensions/Image+OptionalType.swift index ec56140..5b667e1 100644 --- a/Sources/SkeletonUI/Extensions/Image+OptionalType.swift +++ b/Sources/SkeletonUI/Extensions/Image+OptionalType.swift @@ -1,5 +1,8 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public extension Image { #if os(iOS) || os(tvOS) || os(watchOS) init(uiImage: UIImage?) { @@ -100,3 +103,5 @@ public extension Image { } #endif } + +#endif diff --git a/Sources/SkeletonUI/Extensions/ModifiedContent+SkeletonModifier.swift b/Sources/SkeletonUI/Extensions/ModifiedContent+SkeletonModifier.swift index 7031a1e..46c9801 100644 --- a/Sources/SkeletonUI/Extensions/ModifiedContent+SkeletonModifier.swift +++ b/Sources/SkeletonUI/Extensions/ModifiedContent+SkeletonModifier.swift @@ -1,3 +1,5 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) @@ -24,3 +26,5 @@ public extension ModifiedContent where Content: View, Modifier == SkeletonModifi return self } } + +#endif diff --git a/Sources/SkeletonUI/Extensions/Optional+OptionalType.swift b/Sources/SkeletonUI/Extensions/Optional+OptionalType.swift index dba2a5e..37237b3 100644 --- a/Sources/SkeletonUI/Extensions/Optional+OptionalType.swift +++ b/Sources/SkeletonUI/Extensions/Optional+OptionalType.swift @@ -1,5 +1,10 @@ +#if arch(x86_64) || arch(arm64) + +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension Optional: OptionalType { public var wrapped: Wrapped? { self } } + +#endif diff --git a/Sources/SkeletonUI/Extensions/SecureField+OptionalType.swift b/Sources/SkeletonUI/Extensions/SecureField+OptionalType.swift index ca29b1b..e478a25 100644 --- a/Sources/SkeletonUI/Extensions/SecureField+OptionalType.swift +++ b/Sources/SkeletonUI/Extensions/SecureField+OptionalType.swift @@ -1,5 +1,8 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public extension SecureField where Label == Text { init(_ titleKey: LocalizedStringKey?, text: Binding, onCommit: @escaping () -> Void = {}) { if let titleKey = titleKey { @@ -17,3 +20,5 @@ public extension SecureField where Label == Text { } } } + +#endif diff --git a/Sources/SkeletonUI/Extensions/Text+OptionalType.swift b/Sources/SkeletonUI/Extensions/Text+OptionalType.swift index 7f12d97..b7696e1 100644 --- a/Sources/SkeletonUI/Extensions/Text+OptionalType.swift +++ b/Sources/SkeletonUI/Extensions/Text+OptionalType.swift @@ -1,5 +1,8 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public extension Text { init(_ content: S?) where S: OptionalType, S.Wrapped: StringProtocol { if let content = content?.wrapped { @@ -25,3 +28,5 @@ public extension Text { } } } + +#endif diff --git a/Sources/SkeletonUI/Extensions/TextField+OptionalType.swift b/Sources/SkeletonUI/Extensions/TextField+OptionalType.swift index 00e945d..6aa6ba0 100644 --- a/Sources/SkeletonUI/Extensions/TextField+OptionalType.swift +++ b/Sources/SkeletonUI/Extensions/TextField+OptionalType.swift @@ -1,5 +1,8 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public extension TextField where Label == Text { init(titleKey: LocalizedStringKey?, text: Binding, onEditingChanged: @escaping (Bool) -> Void = { _ in }, onCommit: @escaping () -> Void = {}) { if let titleKey = titleKey { @@ -33,3 +36,5 @@ public extension TextField where Label == Text { } } } + +#endif diff --git a/Sources/SkeletonUI/Extensions/Toggle+OptionalType.swift b/Sources/SkeletonUI/Extensions/Toggle+OptionalType.swift index 78ee3fa..84277a6 100644 --- a/Sources/SkeletonUI/Extensions/Toggle+OptionalType.swift +++ b/Sources/SkeletonUI/Extensions/Toggle+OptionalType.swift @@ -1,5 +1,8 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public extension Toggle where Label: View { init(isOn: Binding?, @ViewBuilder label: () -> Label) { if let isOn = isOn { @@ -10,6 +13,7 @@ public extension Toggle where Label: View { } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public extension Toggle where Label == Text { init(_ titleKey: LocalizedStringKey?, isOn: Binding) { if let titleKey = titleKey { @@ -27,3 +31,5 @@ public extension Toggle where Label == Text { } } } + +#endif diff --git a/Sources/SkeletonUI/Extensions/UnitPoint+Angle.swift b/Sources/SkeletonUI/Extensions/UnitPoint+Angle.swift index 831e259..e0f324c 100644 --- a/Sources/SkeletonUI/Extensions/UnitPoint+Angle.swift +++ b/Sources/SkeletonUI/Extensions/UnitPoint+Angle.swift @@ -1,8 +1,13 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) extension UnitPoint { static func point(with position: CGFloat, _ radius: CGFloat, _ angle: CGFloat) -> UnitPoint { let radians = angle * .pi / 180.0 return UnitPoint(x: (position + radius) * cos(radians), y: (position + radius) * sin(radians)) } } + +#endif diff --git a/Sources/SkeletonUI/Extensions/View+SkeletonModifier.swift b/Sources/SkeletonUI/Extensions/View+SkeletonModifier.swift index d140a87..756dc5a 100644 --- a/Sources/SkeletonUI/Extensions/View+SkeletonModifier.swift +++ b/Sources/SkeletonUI/Extensions/View+SkeletonModifier.swift @@ -1,3 +1,5 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) @@ -6,3 +8,5 @@ public extension View { modifier(SkeletonModifier(skeleton: SkeletonInteractor(loading, size: size, transition: transition, animated: animated))) } } + +#endif diff --git a/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift b/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift index e1e6a9a..7350bcc 100644 --- a/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift +++ b/Sources/SkeletonUI/Modifiers/SkeletonModifier.swift @@ -1,3 +1,5 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) @@ -41,3 +43,5 @@ public struct SkeletonModifier: ViewModifier { .animation(skeleton.presenter.animated, value: skeleton.presenter.loading) } } + +#endif diff --git a/Sources/SkeletonUI/Multiline/MultilineInteractor.swift b/Sources/SkeletonUI/Multiline/MultilineInteractor.swift index 0a7377b..8755dea 100644 --- a/Sources/SkeletonUI/Multiline/MultilineInteractor.swift +++ b/Sources/SkeletonUI/Multiline/MultilineInteractor.swift @@ -1,7 +1,10 @@ +#if arch(x86_64) || arch(arm64) + import Combine import SwiftUI // sourcery: AutoMockable +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) protocol MultilineInteractable: AnyObject { var presenter: MultilinePresenter { get } var line: CurrentValueSubject { get } @@ -11,6 +14,7 @@ protocol MultilineInteractable: AnyObject { var scales: CurrentValueSubject<[Int: CGFloat]?, Never> { get } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class MultilineInteractor: MultilineInteractable { let presenter = MultilinePresenter() let line: CurrentValueSubject @@ -39,3 +43,5 @@ final class MultilineInteractor: MultilineInteractable { spacing.assign(to: \.spacing, on: presenter).store(in: &cancellables) } } + +#endif diff --git a/Sources/SkeletonUI/Multiline/MultilinePresenter.swift b/Sources/SkeletonUI/Multiline/MultilinePresenter.swift index 4ba0891..bd4e50f 100644 --- a/Sources/SkeletonUI/Multiline/MultilinePresenter.swift +++ b/Sources/SkeletonUI/Multiline/MultilinePresenter.swift @@ -1,5 +1,8 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class MultilinePresenter: ObservableObject { @Published var line: Int = 0 @Published var lines: Int = 1 @@ -7,3 +10,5 @@ final class MultilinePresenter: ObservableObject { @Published var scale: CGFloat = 1 @Published var scales: [Int: CGFloat]? } + +#endif diff --git a/Sources/SkeletonUI/Opacity/OpacityInteractor.swift b/Sources/SkeletonUI/Opacity/OpacityInteractor.swift index b77b83e..2dff2f8 100644 --- a/Sources/SkeletonUI/Opacity/OpacityInteractor.swift +++ b/Sources/SkeletonUI/Opacity/OpacityInteractor.swift @@ -1,7 +1,10 @@ +#if arch(x86_64) || arch(arm64) + import Combine import SwiftUI // sourcery: AutoMockable +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) protocol OpacityInteractable: AnyObject { var presenter: OpacityPresenter { get } var animation: CurrentValueSubject { get } @@ -9,6 +12,7 @@ protocol OpacityInteractable: AnyObject { var range: CurrentValueSubject, Never> { get } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class OpacityInteractor: OpacityInteractable { let presenter = OpacityPresenter() let animation: CurrentValueSubject @@ -27,3 +31,5 @@ final class OpacityInteractor: OpacityInteractable { range.map { $0.lowerBound }.assign(to: \.value, on: presenter).store(in: &cancellables) } } + +#endif diff --git a/Sources/SkeletonUI/Opacity/OpacityPresenter.swift b/Sources/SkeletonUI/Opacity/OpacityPresenter.swift index 6367612..f42e636 100644 --- a/Sources/SkeletonUI/Opacity/OpacityPresenter.swift +++ b/Sources/SkeletonUI/Opacity/OpacityPresenter.swift @@ -1,7 +1,12 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class OpacityPresenter: ObservableObject { @Published var animation: Animation? @Published var value: Double = .zero @Published var range: ClosedRange = .zero ... 1 } + +#endif diff --git a/Sources/SkeletonUI/Position/PositionInteractor.swift b/Sources/SkeletonUI/Position/PositionInteractor.swift index eace37f..86a79b1 100644 --- a/Sources/SkeletonUI/Position/PositionInteractor.swift +++ b/Sources/SkeletonUI/Position/PositionInteractor.swift @@ -1,7 +1,10 @@ +#if arch(x86_64) || arch(arm64) + import Combine import SwiftUI // sourcery: AutoMockable +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) protocol PositionInteractable: AnyObject { var presenter: PositionPresenter { get } var animation: CurrentValueSubject { get } @@ -9,6 +12,7 @@ protocol PositionInteractable: AnyObject { var range: CurrentValueSubject, Never> { get } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class PositionInteractor: PositionInteractable { let presenter = PositionPresenter() let animation: CurrentValueSubject @@ -27,3 +31,5 @@ final class PositionInteractor: PositionInteractable { range.map { $0.lowerBound }.assign(to: \.value, on: presenter).store(in: &cancellables) } } + +#endif diff --git a/Sources/SkeletonUI/Position/PositionPresenter.swift b/Sources/SkeletonUI/Position/PositionPresenter.swift index 8d24835..ceea573 100644 --- a/Sources/SkeletonUI/Position/PositionPresenter.swift +++ b/Sources/SkeletonUI/Position/PositionPresenter.swift @@ -1,7 +1,12 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class PositionPresenter: ObservableObject { @Published var animation: Animation? @Published var value: CGFloat = .zero @Published var range: ClosedRange = .zero ... 1 } + +#endif diff --git a/Sources/SkeletonUI/Protocols/OptionalType.swift b/Sources/SkeletonUI/Protocols/OptionalType.swift index f1cb7cb..8c3ada1 100644 --- a/Sources/SkeletonUI/Protocols/OptionalType.swift +++ b/Sources/SkeletonUI/Protocols/OptionalType.swift @@ -1,4 +1,9 @@ +#if arch(x86_64) || arch(arm64) + +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public protocol OptionalType { associatedtype Wrapped var wrapped: Wrapped? { get } } + +#endif diff --git a/Sources/SkeletonUI/Radius/RadiusInteractor.swift b/Sources/SkeletonUI/Radius/RadiusInteractor.swift index 0792c62..266c352 100644 --- a/Sources/SkeletonUI/Radius/RadiusInteractor.swift +++ b/Sources/SkeletonUI/Radius/RadiusInteractor.swift @@ -1,7 +1,10 @@ +#if arch(x86_64) || arch(arm64) + import Combine import SwiftUI // sourcery: AutoMockable +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) protocol RadiusInteractable: AnyObject { var presenter: RadiusPresenter { get } var animation: CurrentValueSubject { get } @@ -9,6 +12,7 @@ protocol RadiusInteractable: AnyObject { var range: CurrentValueSubject, Never> { get } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class RadiusInteractor: RadiusInteractable { let presenter = RadiusPresenter() let animation: CurrentValueSubject @@ -27,3 +31,4 @@ final class RadiusInteractor: RadiusInteractable { range.map { $0.lowerBound }.assign(to: \.value, on: presenter).store(in: &cancellables) } } +#endif diff --git a/Sources/SkeletonUI/Radius/RadiusPresenter.swift b/Sources/SkeletonUI/Radius/RadiusPresenter.swift index 3f916cc..ea1d5ff 100644 --- a/Sources/SkeletonUI/Radius/RadiusPresenter.swift +++ b/Sources/SkeletonUI/Radius/RadiusPresenter.swift @@ -1,7 +1,12 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class RadiusPresenter: ObservableObject { @Published var animation: Animation? @Published var value: CGFloat = .zero @Published var range: ClosedRange = 1 ... 40 } + +#endif diff --git a/Sources/SkeletonUI/Shape/ShapeInteractor.swift b/Sources/SkeletonUI/Shape/ShapeInteractor.swift index a86df38..dd66ab0 100644 --- a/Sources/SkeletonUI/Shape/ShapeInteractor.swift +++ b/Sources/SkeletonUI/Shape/ShapeInteractor.swift @@ -1,11 +1,14 @@ -import Combine +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public enum RoundedType: Equatable { case radius(CGFloat, style: RoundedCornerStyle = .continuous) case size(CGSize, style: RoundedCornerStyle = .continuous) } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) public enum ShapeType: Equatable { case rounded(RoundedType) case rectangle @@ -15,11 +18,13 @@ public enum ShapeType: Equatable { } // sourcery: AutoMockable +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) protocol ShapeInteractable: AnyObject { var presenter: ShapePresenter { get } var type: CurrentValueSubject { get } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class ShapeInteractor: ShapeInteractable { let presenter = ShapePresenter() let type: CurrentValueSubject @@ -31,3 +36,5 @@ final class ShapeInteractor: ShapeInteractable { type.assign(to: \.type, on: presenter).store(in: &cancellables) } } + +#endif diff --git a/Sources/SkeletonUI/Shape/ShapePresenter.swift b/Sources/SkeletonUI/Shape/ShapePresenter.swift index 9383772..c60a91d 100644 --- a/Sources/SkeletonUI/Shape/ShapePresenter.swift +++ b/Sources/SkeletonUI/Shape/ShapePresenter.swift @@ -1,5 +1,10 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class ShapePresenter: ObservableObject { @Published var type: ShapeType = .capsule } + +#endif diff --git a/Sources/SkeletonUI/Skeleton/SkeletonForEach.swift b/Sources/SkeletonUI/Skeleton/SkeletonForEach.swift index 1cd52a9..ce0695a 100644 --- a/Sources/SkeletonUI/Skeleton/SkeletonForEach.swift +++ b/Sources/SkeletonUI/Skeleton/SkeletonForEach.swift @@ -1,3 +1,5 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) @@ -18,3 +20,5 @@ public struct SkeletonForEach: View where Data: RandomAccessColle } } } + +#endif diff --git a/Sources/SkeletonUI/Skeleton/SkeletonInteractor.swift b/Sources/SkeletonUI/Skeleton/SkeletonInteractor.swift index 5bec5fd..201a63b 100644 --- a/Sources/SkeletonUI/Skeleton/SkeletonInteractor.swift +++ b/Sources/SkeletonUI/Skeleton/SkeletonInteractor.swift @@ -1,7 +1,9 @@ +#if arch(x86_64) || arch(arm64) + import Combine import SwiftUI -// sourcery: AutoMockable +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) protocol SkeletonInteractable: AnyObject { var presenter: SkeletonPresenter { get } var shape: ShapeInteractable { get } @@ -10,6 +12,7 @@ protocol SkeletonInteractable: AnyObject { var animation: AnimationInteractable { get } } +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class SkeletonInteractor: SkeletonInteractable { let presenter: SkeletonPresenter let shape: ShapeInteractable @@ -25,3 +28,5 @@ final class SkeletonInteractor: SkeletonInteractable { self.animation = animation } } + +#endif diff --git a/Sources/SkeletonUI/Skeleton/SkeletonList.swift b/Sources/SkeletonUI/Skeleton/SkeletonList.swift index 10fb78d..8f12cfe 100644 --- a/Sources/SkeletonUI/Skeleton/SkeletonList.swift +++ b/Sources/SkeletonUI/Skeleton/SkeletonList.swift @@ -1,3 +1,5 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) @@ -18,3 +20,5 @@ public struct SkeletonList: View where Data: RandomAccessCollecti } } } + +#endif diff --git a/Sources/SkeletonUI/Skeleton/SkeletonPresenter.swift b/Sources/SkeletonUI/Skeleton/SkeletonPresenter.swift index c68ed8a..2722f5f 100644 --- a/Sources/SkeletonUI/Skeleton/SkeletonPresenter.swift +++ b/Sources/SkeletonUI/Skeleton/SkeletonPresenter.swift @@ -1,5 +1,8 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) final class SkeletonPresenter: ObservableObject { @Published var loading: Bool @Published var size: CGSize? @@ -13,3 +16,5 @@ final class SkeletonPresenter: ObservableObject { self.animated = animated ?? .default } } + +#endif diff --git a/Sources/SkeletonUI/Skeleton/SkeletonShape.swift b/Sources/SkeletonUI/Skeleton/SkeletonShape.swift index 795cadc..705310b 100644 --- a/Sources/SkeletonUI/Skeleton/SkeletonShape.swift +++ b/Sources/SkeletonUI/Skeleton/SkeletonShape.swift @@ -1,5 +1,8 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) struct SkeletonShape: Shape { @ObservedObject private var angle: AnglePresenter @ObservedObject private var shape: ShapePresenter @@ -62,3 +65,5 @@ struct SkeletonShape: Shape { } } } + +#endif diff --git a/Sources/SkeletonUI/Skeleton/SkeletonView.swift b/Sources/SkeletonUI/Skeleton/SkeletonView.swift index 272d78d..378ef8a 100644 --- a/Sources/SkeletonUI/Skeleton/SkeletonView.swift +++ b/Sources/SkeletonUI/Skeleton/SkeletonView.swift @@ -1,5 +1,8 @@ +#if arch(x86_64) || arch(arm64) + import SwiftUI +@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) struct SkeletonView: View { private var shape: ShapePresenter private var angle: AnglePresenter @@ -23,3 +26,5 @@ struct SkeletonView: View { SkeletonShape(angle: angle, shape: shape, radius: radius, opacity: opacity, position: position, appearance: appearance) } } + +#endif From 50df0d7cf68b924669c17321ab0c2e1f2d771f46 Mon Sep 17 00:00:00 2001 From: Alex Marchant Date: Thu, 20 Jan 2022 21:27:25 +0100 Subject: [PATCH 2/4] Add missing Combine module import --- Sources/SkeletonUI/Shape/ShapeInteractor.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/SkeletonUI/Shape/ShapeInteractor.swift b/Sources/SkeletonUI/Shape/ShapeInteractor.swift index dd66ab0..4c405b4 100644 --- a/Sources/SkeletonUI/Shape/ShapeInteractor.swift +++ b/Sources/SkeletonUI/Shape/ShapeInteractor.swift @@ -1,5 +1,6 @@ #if arch(x86_64) || arch(arm64) +import Combine import SwiftUI @available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) From fb4094acb7d21315cb2b788b9a35febb72add1dc Mon Sep 17 00:00:00 2001 From: Alex Marchant Date: Thu, 2 Jun 2022 18:02:58 +0200 Subject: [PATCH 3/4] Reduce os targets to 12 --- SkeletonUI.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SkeletonUI.podspec b/SkeletonUI.podspec index 6f3f80d..8097bef 100644 --- a/SkeletonUI.podspec +++ b/SkeletonUI.podspec @@ -10,8 +10,8 @@ SkeletonUI aims to bring an elegant, declarative syntax to skeleton loading anim s.author = { 'CSolanaM' => 'carlos.solana.martinez@gmail.com' } s.source = { :git => 'https://github.com/CSolanaM/SkeletonUI.git', :tag => s.version.to_s } s.social_media_url = 'https://twitter.com/CSolanaM' - s.ios.deployment_target = '13.0' - s.tvos.deployment_target = '13.0' + s.ios.deployment_target = '12.0' + s.tvos.deployment_target = '12.0' s.watchos.deployment_target = '6.0' s.macos.deployment_target = '10.15' s.swift_version = '5.0' From 56b71c9db775035758818afa9fe03a5845631c35 Mon Sep 17 00:00:00 2001 From: Alex Marchant Date: Thu, 30 Jun 2022 18:37:55 +0200 Subject: [PATCH 4/4] Add SwiftUI as a weak framework --- SkeletonUI.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/SkeletonUI.podspec b/SkeletonUI.podspec index 8097bef..0bdab3b 100644 --- a/SkeletonUI.podspec +++ b/SkeletonUI.podspec @@ -16,4 +16,5 @@ SkeletonUI aims to bring an elegant, declarative syntax to skeleton loading anim s.macos.deployment_target = '10.15' s.swift_version = '5.0' s.source_files = 'Sources/SkeletonUI/**/*' + s.weak_framework = 'SwiftUI' end