Skip to content

Commit

Permalink
Update the FlareUI package to Swift 6.0 (#93)
Browse files Browse the repository at this point in the history
* Update the `FlareUI` package to Swift 6.0

* Update `CHANGELOG.md`

* Resolve CI failures on older versions
  • Loading branch information
ns-vasilev authored Dec 27, 2024
1 parent dcca329 commit ab60798
Show file tree
Hide file tree
Showing 75 changed files with 355 additions and 192 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file.

## Added
- Update the FlareUI package to Swift 6.0.
- Added in Pull Request [#93](https://github.com/space-code/flare/pull/93).
- Add full Swift concurrency support with Sendable requirements.
- Added in Pull Request [#92](https://github.com/space-code/flare/pull/92).
- Implement locale for StoreProduct
Expand All @@ -13,13 +15,13 @@ All notable changes to this project will be documented in this file.
- Update `README.md`
- Updated in Pull Request [#70](https://github.com/space-code/flare/pull/70).
- Update Transaction Model with price and currency
- Updated in Pull Request [#84](https://github.com/space-code/flare/pull/84)
- Updated in Pull Request [#84](https://github.com/space-code/flare/pull/84).
- Update RenewalInfo Model with renewalPrice and currency
- Updated in Pull Request [#85](https://github.com/space-code/flare/pull/85)
- Updated in Pull Request [#85](https://github.com/space-code/flare/pull/85).

## Fixed
- Fix the GitHub Actions Pipeline
- Fixed in Pull Request [#88](https://github.com/space-code/flare/pull/88)
- Fixed in Pull Request [#88](https://github.com/space-code/flare/pull/88).

#### 3.x Releases
- `3.0.x` Releases - [`3.0.0`](#300) | [`3.0.1`](#301) | [`3.0.2`](#302)
Expand Down
11 changes: 5 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ let package = Package(
.target(
name: "FlareUI",
dependencies: ["Flare"],
resources: [.process("Resources")],
swiftSettings: [.swiftLanguageMode(.v5)]
resources: [.process("Resources")] // ,
// swiftSettings: [.swiftLanguageMode(.v5)]
),
.target(name: "FlareMock", dependencies: ["Flare"]),
.target(name: "FlareUIMock", dependencies: ["FlareMock", "FlareUI"]),
Expand All @@ -63,8 +63,8 @@ let package = Package(
"FlareUI",
"FlareMock",
"FlareUIMock",
],
swiftSettings: [.swiftLanguageMode(.v5)]
] // ,
// swiftSettings: [.swiftLanguageMode(.v5)]
),
.testTarget(
name: "SnapshotTests",
Expand All @@ -74,6 +74,5 @@ let package = Package(
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
]
),
] // ,
// swiftLanguageModes: [.v5]
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import SwiftUI

struct AnyProductStyle: IProductStyle {
struct AnyProductStyle: IProductStyle, @unchecked Sendable {
// MARK: Properties

/// A private property to hold the closure that creates the body of the view
Expand All @@ -16,7 +16,7 @@ struct AnyProductStyle: IProductStyle {
/// Initializes the `AnyProductStyle` with a specific style conforming to `IProductStyle`.
///
/// - Parameter style: A product style.
init<S: IProductStyle>(style: S) {
init(style: some IProductStyle) {
_makeBody = { configuration in
AnyView(style.makeBody(configuration: configuration))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,19 @@ struct AnySubscriptionControlStyle: ISubscriptionControlStyle {

let style: any ISubscriptionControlStyle

/// A private property to hold the closure that creates the body of the view
private var _makeBody: (Configuration) -> AnyView

// MARK: Initialization

/// Initializes the `AnyProductStyle` with a specific style conforming to `IProductStyle`.
///
/// - Parameter style: A product style.
init<S: ISubscriptionControlStyle>(style: S) {
init(style: some ISubscriptionControlStyle) {
self.style = style
_makeBody = { configuration in
AnyView(style.makeBody(configuration: configuration))
}
}

// MARK: IProductStyle

/// Implements the makeBody method required by `IProductStyle`.
func makeBody(configuration: Configuration) -> some View {
_makeBody(configuration)
AnyView(style.makeBody(configuration: configuration))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - ProductAssemblyKey

private struct ProductAssemblyKey: EnvironmentKey {
static var defaultValue: IProductViewAssembly?
static let defaultValue: IProductViewAssembly? = nil
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - StoreButtonsAssemblyKey

private struct StoreButtonsAssemblyKey: EnvironmentKey {
static var defaultValue: IStoreButtonsAssembly?
static var defaultValue: IStoreButtonsAssembly? { nil }
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

#if os(iOS) || os(tvOS)
private struct BlurEffectStyleKey: EnvironmentKey {
static var defaultValue: UIBlurEffect.Style = .light
static let defaultValue: UIBlurEffect.Style = .light
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

@available(watchOS, unavailable)
private struct PoliciesButtonStyleKey: EnvironmentKey {
static var defaultValue: AnyPoliciesButtonStyle = .init(style: AutomaticPoliciesButtonStyle())
static var defaultValue: AnyPoliciesButtonStyle { .init(style: AutomaticPoliciesButtonStyle()) }
}

@available(watchOS, unavailable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - ProductStyleKey

private struct ProductStyleKey: EnvironmentKey {
static var defaultValue = AnyProductStyle(style: CompactProductStyle())
static var defaultValue: AnyProductStyle { AnyProductStyle(style: CompactProductStyle()) }
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import Flare
import SwiftUI

public typealias PurchaseCompletionHandler = (StoreProduct, Result<StoreTransaction, Error>) -> Void
public typealias PurchaseCompletionHandler = @Sendable (StoreProduct, Result<StoreTransaction, Error>) -> Void

// MARK: - PurchaseCompletionKey

private struct PurchaseCompletionKey: EnvironmentKey {
static var defaultValue: PurchaseCompletionHandler?
static let defaultValue: PurchaseCompletionHandler? = nil
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import Flare
import StoreKit
import SwiftUI

typealias PurchaseOptionHandler = (StoreProduct) -> PurchaseOptions
typealias PurchaseOptionHandler = @Sendable (StoreProduct) -> PurchaseOptions

// MARK: - PurchaseOptionKey

private struct PurchaseOptionKey: EnvironmentKey {
static var defaultValue: PurchaseOptionHandler?
static let defaultValue: PurchaseOptionHandler? = nil
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - StoreButtonKey

private struct StoreButtonKey: EnvironmentKey {
static var defaultValue: [StoreButtonType] = []
static var defaultValue: [StoreButtonType] { [] }
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - StoreButtonViewFontWeightKey

private struct StoreButtonViewFontWeightKey: EnvironmentKey {
static var defaultValue: Font.Weight = .regular
static let defaultValue: Font.Weight = .regular
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionBackgroundKey

private struct SubscriptionBackgroundKey: EnvironmentKey {
static var defaultValue: Color = Palette.systemBackground
static let defaultValue: Color = Palette.systemBackground
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

@available(watchOS, unavailable)
private struct SubscriptionControlStyleKey: EnvironmentKey {
static var defaultValue: AnySubscriptionControlStyle = .init(style: .automatic)
static var defaultValue: AnySubscriptionControlStyle { .init(style: .automatic) }
}

@available(watchOS, unavailable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionHeaderContentBackgroundKey

private struct SubscriptionHeaderContentBackgroundKey: EnvironmentKey {
static var defaultValue: Color = .clear
static let defaultValue: Color = .clear
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionMarketingContentKey

private struct SubscriptionMarketingContentKey: EnvironmentKey {
static var defaultValue: AnyView?
static var defaultValue: AnyView? { nil }
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionPickerItemBackgroundKey

private struct SubscriptionPickerItemBackgroundKey: EnvironmentKey {
static var defaultValue: Color = Palette.systemGray5
static let defaultValue: Color = Palette.systemGray5
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionPrivacyPolicyDestinationKey

private struct SubscriptionPrivacyPolicyDestinationKey: EnvironmentKey {
static var defaultValue: AnyView?
static var defaultValue: AnyView? { nil }
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionPrivacyPolicyURLKey

private struct SubscriptionPrivacyPolicyURLKey: EnvironmentKey {
static var defaultValue: URL?
static let defaultValue: URL? = nil
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionStoreButtonLabelKey

private struct SubscriptionStoreButtonLabelKey: EnvironmentKey {
static var defaultValue: SubscriptionStoreButtonLabel = .action
static var defaultValue: SubscriptionStoreButtonLabel { .action }
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionTermsOfServiceDestinationKey

private struct SubscriptionTermsOfServiceDestinationKey: EnvironmentKey {
static var defaultValue: AnyView?
static var defaultValue: AnyView? { nil }
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionTermsOfServiceURLKey

private struct SubscriptionTermsOfServiceURLKey: EnvironmentKey {
static var defaultValue: URL?
static let defaultValue: URL? = nil
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - SubscriptionViewTintKey

private struct SubscriptionViewTintKey: EnvironmentKey {
static var defaultValue: Color = .blue
static let defaultValue: Color = .blue
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import SwiftUI

@available(watchOS, unavailable)
private struct SubscriptionsWrapperViewStyleKey: EnvironmentKey {
static var defaultValue = AnySubscriptionsWrapperViewStyle(style: AutomaticSubscriptionsWrapperViewStyle())
static var defaultValue: AnySubscriptionsWrapperViewStyle {
AnySubscriptionsWrapperViewStyle(style: AutomaticSubscriptionsWrapperViewStyle())
}
}

@available(watchOS, unavailable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SwiftUI
// MARK: - TintColorKey

private struct TintColorKey: EnvironmentKey {
static var defaultValue: Color = .blue
static var defaultValue: Color { .blue }
}

extension EnvironmentValues {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation
// MARK: - IDateComponentsFormatter

/// A type that creates string representations of quantities of time.
protocol IDateComponentsFormatter {
protocol IDateComponentsFormatter: Sendable {
/// The bitmask of calendrical units such as day and month to include in the output string.
var allowedUnits: NSCalendar.Unit { get set }

Expand Down
2 changes: 1 addition & 1 deletion Sources/FlareUI/Classes/Core/Models/PurchaseOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import StoreKit

/// Struct representing purchase options for a product.
struct PurchaseOptions {
struct PurchaseOptions: @unchecked Sendable {
// MARK: Properties

/// Internal storage for purchase options.
Expand Down
7 changes: 5 additions & 2 deletions Sources/FlareUI/Classes/FlareUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ public final class FlareUI: IFlareUI {
private let configurationProvider: IConfigurationProvider

/// The singleton instance.
private static let flareUI: FlareUI = .init()

#if swift(>=6.0)
private nonisolated(unsafe) static let flareUI: FlareUI = .init()
#else
private static let flareUI: FlareUI = .init()
#endif
/// Returns a shared `Flare` object.
public static var shared: IFlareUI { flareUI }

Expand Down
2 changes: 1 addition & 1 deletion Sources/FlareUI/Classes/Generated/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enum Asset {

// swiftlint:enable identifier_name line_length nesting type_body_length type_name

final class ColorAsset {
final class ColorAsset: @unchecked Sendable {
fileprivate(set) var name: String

#if os(macOS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ import SwiftUI
///
/// - Parameter options: A closure that returns the purchase options for a given store product.
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
func inAppPurchaseOptions(_ options: ((StoreProduct) -> Set<Product.PurchaseOption>?)?) {
func inAppPurchaseOptions(_ options: (@Sendable (StoreProduct) -> Set<Product.PurchaseOption>?)?) {
viewModel.inAppPurchaseOptions = { PurchaseOptions(options: options?($0) ?? []) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ import SwiftUI
///
/// - Parameter options: A closure that returns the purchase options for a given store product.
@available(iOS 15.0, tvOS 15.0, macOS 12.0, *)
func inAppPurchaseOptions(_ options: ((StoreProduct) -> Set<Product.PurchaseOption>?)?) {
func inAppPurchaseOptions(_ options: (@Sendable (StoreProduct) -> Set<Product.PurchaseOption>?)?) {
viewModel.inAppPurchaseOptions = { PurchaseOptions(options: options?($0) ?? []) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ import SwiftUI
///
/// - Parameter options: A closure that returns the purchase options for a given store product.
@available(iOS 15.0, tvOS 15.0, macOS 12.0, *)
func inAppPurchaseOptions(_ options: ((StoreProduct) -> Set<Product.PurchaseOption>?)?) {
func inAppPurchaseOptions(_ options: (@Sendable (StoreProduct) -> Set<Product.PurchaseOption>?)?) {
viewModel.inAppPurchaseOptions = { PurchaseOptions(options: options?($0) ?? []) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI
@available(iOS 13.0, macOS 11.0, *)
@available(watchOS, unavailable)
@available(tvOS, unavailable)
@MainActor
final class SubscriptionsViewControllerViewModel: ObservableObject {
@Published var onInAppPurchaseCompletion: PurchaseCompletionHandler?
@Published var inAppPurchaseOptions: PurchaseOptionHandler?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation
// MARK: - StoreButtonType

/// Enum representing different types of buttons in a store.
public enum StoreButtonType {
public enum StoreButtonType: Sendable {
/// Button for restoring purchases.
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *)
case restore
Expand Down
Loading

0 comments on commit ab60798

Please sign in to comment.