Skip to content

Commit 65f451a

Browse files
committed
Update docs
1 parent 3e33ff0 commit 65f451a

File tree

9 files changed

+46
-93
lines changed

9 files changed

+46
-93
lines changed

Sources/StoreKitPlus/Products/BasicProduct.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77

88
import StoreKit
99

10-
/// This struct is a basic prroduct representation, that you
11-
/// can use to define your products with just an ID and name.
10+
/// This basic product representation can be used to refer to an App Store product
11+
/// with just its ID and name.
1212
///
13-
/// The ``StoreContext`` is extended with more ways to fetch
14-
/// product information for a basic product.
13+
/// The ``StoreContext`` has ways to fetch product info for a basic product.
1514
public struct BasicProduct: Identifiable, ProductRepresentable, Sendable {
1615

1716
/// Create a basic product representation.

Sources/StoreKitPlus/Products/Product+YearlySaving.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import StoreKit
1010

1111
public extension Product {
1212

13-
/// Get a yearly savings in percentages when comparing a
14-
/// yearly product with a monthy one.
13+
/// Calculate a yearly savings percentage when comparing a yearly product
14+
/// with a monthy one.
1515
///
1616
/// - Returns: A raw 0-1 percentage.
1717
static func yearlySavingsPercentage(
@@ -24,8 +24,8 @@ public extension Product {
2424
)
2525
}
2626

27-
/// Get a yearly savings in percentages when comparing a
28-
/// yearly price with a monthy one.
27+
/// Calculate a yearly savings percentage when comparing a yearly product
28+
/// price with a monthy one.
2929
///
3030
/// - Returns: A raw 0-1 percentage.
3131
static func yearlySavingsPercentage(
@@ -38,8 +38,8 @@ public extension Product {
3838
return percentage
3939
}
4040

41-
/// Get a yearly savings in percentages when comparing a
42-
/// yearly product with a monthy product variant.
41+
/// Calculate a yearly savings percentage when comparing a yearly product
42+
/// with a monthy one, and represent it as a 0-100 percentage.
4343
///
4444
/// - Returns: A 0-100 (not 0-1) display percentage.
4545
static func yearlySavingsDisplayPercentage(
@@ -52,8 +52,8 @@ public extension Product {
5252
)
5353
}
5454

55-
/// Get a yearly savings in percentages when comparing a
56-
/// yearly product with a monthy product variant.
55+
/// Calculate a yearly savings percentage when comparing a yearly product
56+
/// price with a monthy one, and represent it as a 0-100 percentage.
5757
///
5858
/// - Returns: A 0-100 (not 0-1) display percentage.
5959
static func yearlySavingsDisplayPercentage(

Sources/StoreKitPlus/Products/ProductRepresentable.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88

99
import Foundation
1010

11-
/// This protocol can be implemented by types that should be
12-
/// able to represent a StoreKit product.
11+
/// This protocol can be implemented by types that represent a StoreKit product.
1312
///
14-
/// This protocol can be used to define a local product that
15-
/// uses the same product ID as a real StoreKit product. The
16-
/// local product can then be used to provide any additional
17-
/// information, unit test product-based logic, present your
18-
/// products even if the app is unable to sync with StoreKit,
19-
/// e.g. when it is offline, etc.
13+
/// This protocol can be used to define a local product that uses the same product
14+
/// ID as a real StoreKit product. The local product can then provide any additional
15+
/// information, unit test product-based logic, present your products even if the app
16+
/// is unable to sync with StoreKit, e.g. when it is offline, etc.
2017
public protocol ProductRepresentable: Identifiable {
2118

2219
var id: ProductID { get }

Sources/StoreKitPlus/Products/ProductUsp.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import SwiftUI
1010

1111
/// This type defines a "unique selling point" for a product.
1212
///
13-
/// A USP is a way to specify a list of reasons why a person
14-
/// should purchase your product.
15-
///
16-
/// A USP can be rendered with a ``ProductUsp/Label`` and an
17-
/// array of USPs with a ``ProductUsp/LabelStack``.
13+
/// Listing USPs is a way to tell people why they should purchase your product. A
14+
/// USP can be rendered with a ``ProductUsp/Label`` and an array of USPs
15+
/// can be rendered with a ``ProductUsp/LabelStack``.
1816
public struct ProductUsp {
1917

2018
/// Create a custom USP.

Sources/StoreKitPlus/Services/StandardStoreService.swift

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ public extension StoreService where Self == StandardStoreService {
3131
}
3232
}
3333

34-
/// This class implements the ``StoreService`` protocol, and
35-
/// can be used to integrate with StoreKit.
34+
/// This class can be used to integrate with StoreKit.
3635
///
37-
/// You can use this service with a local product collection,
38-
/// by adding a StoreKit configuration file to the app.
36+
/// You can use this service with local products by adding a StoreKit configuration
37+
/// file to your app.
3938
///
40-
/// You can use the two ``StoreService/standard(products:)``
41-
/// shorthands to easily create a standard service instance.
39+
/// You can use the ``StoreService/standard(products:)`` shorthands
40+
/// to easily create a standard service instance.
4241
open class StandardStoreService: StoreService {
4342

4443
/// Create a service instance for the provided IDs.
@@ -134,8 +133,8 @@ open class StandardStoreService: StoreService {
134133
return result.isValid ? result : nil
135134
}
136135

137-
/// This function is called by the initializer, and will
138-
/// fetch transaction updates and try to verify them.
136+
/// This function is called by the initializer, and will fetch transaction updates
137+
/// and try to verify them.
139138
open func updateTransactionsOnLaunch() {
140139
Task.detached {
141140
for await result in Transaction.updates {

Sources/StoreKitPlus/Services/StoreService.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
import StoreKit
1010

11-
/// This protocol can be implemented by any classes that can
12-
/// be used to fetch and purchase products, restore purchase
13-
/// information, etc.
11+
/// This protocol can be implemented by types that can fetch product information,
12+
/// purchase products, restore purchase information, etc.
1413
///
15-
/// Although some operations can be performed directly using
16-
/// StoreKit like `Product.products(for:)`, the service lets
17-
/// you customize any part of the StoreKit integration.
14+
/// Although many operations can be performed by using the StoreKit APIs directly,
15+
/// like using `Product.products(for:)` to fetch products, a store service
16+
/// can be used as a layer between the app and StoreKit, and can also be used to
17+
/// customize or mock the integration, e.g. in tests.
1818
public protocol StoreService {
1919

2020
/// Get all available products.

Sources/StoreKitPlus/StoreContext+Products.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public extension StoreContext {
2222

2323
/// Get a product with a certain ID.
2424
///
25-
/// This function will only return a matching product if
26-
/// the ``products`` array has been synced with StoreKit.
25+
/// This will only return a matching product if the ``products`` array has
26+
/// been synced with StoreKit.
2727
///
2828
/// - Parameters:
2929
/// - id: The ID of the product to fetch.

Sources/StoreKitPlus/StoreContext.swift

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,17 @@
88

99
import StoreKit
1010

11-
/// This observable class can manage store-based information
12-
/// in a way that makes it observable.
11+
/// This observable class can manage store-based state in an observable way.
1312
///
14-
/// You can use the ``StandardStoreService`` to sync product
15-
/// info with this context, which will update the ``products``
16-
/// array with matching products.
13+
/// You can use the ``StandardStoreService`` to sync product information
14+
/// with a context instance when performing certain operations.
1715
///
18-
/// Since StoreKit `Product` isn't `Codable`, the ``products``
19-
/// array is not permanently persisted, which means that the
20-
/// property will reset when the app is restarted.
21-
///
22-
/// Due to this, there's also a ``productIds`` property that
23-
/// is permanently persisted. It gives you the option to map
24-
/// ``productIds`` to local product representations whenever
25-
/// the app can't access StoreKit.
26-
///
27-
/// However, a StoreKit `Product` value is needed to perform
28-
/// a purchase. If your app fails to fetch products, e.g. if
29-
/// it's offline, you should show a spinner or an alert that
30-
/// informs your users that your products can't be retrieved.
16+
/// Since StoreKit `Product` isn't `Codable`, the ``products`` array isn't
17+
/// permanently persisted. This means that it will reset when the app is restarted.
18+
/// Due to this, there's also a ``productIds`` property that *is* permanently
19+
/// persisted. This gives you an option to map ``productIds`` to local product
20+
/// representations whenever the app can't access StoreKit. However, note that a
21+
/// StoreKit `Product` is needed to perform a purchase.
3122
public class StoreContext: ObservableObject, @unchecked Sendable {
3223

3324
/// Create a context instance.
@@ -41,49 +32,23 @@ public class StoreContext: ObservableObject, @unchecked Sendable {
4132
}
4233

4334
/// A list of synced products.
44-
///
45-
/// You can use this property to keep track of a product
46-
/// collection that has been fetched from StoreKit.
47-
///
48-
/// Since `Product` isn't `Codable`, this property can't
49-
/// be persisted and must be reloaded on app launch.
5035
@Published
5136
public var products: [Product] {
5237
didSet { productIds = products.map { $0.id} }
5338
}
5439

55-
/// A list of synced products IDs.
56-
///
57-
/// You can use this property to keep track of a product
58-
/// collection that has been fetched from StoreKit.
59-
///
60-
/// This property is persisted, which means that you can
61-
/// map these IDs to a local product representation when
62-
/// a StoreKit request fails.
40+
/// A persisted list of synced products IDs.
6341
@Published
6442
public internal(set) var productIds: [String] = [] {
6543
willSet { persistedProductIds = newValue }
6644
}
6745

6846
/// A list of active purchase transactions.
69-
///
70-
/// You can use this property to keep track of purchased
71-
/// products that has been fetched from StoreKit.
72-
///
73-
/// Since `Transaction` isn't `Codable` this property is
74-
/// not persisted and must be reloaded on app launch.
7547
public var purchaseTransactions: [Transaction] = [] {
7648
didSet { purchasedProductIds = purchaseTransactions.map { $0.productID } }
7749
}
7850

7951
/// A list of purchased product IDs.
80-
///
81-
/// You can use this property to keep track of purchased
82-
/// products that has been fetched from StoreKit.
83-
///
84-
/// This property is persisted, which means that you can
85-
/// map these IDs to a local product representation when
86-
/// a StoreKit request fails.
8752
@Published
8853
public internal(set) var purchasedProductIds: [String] = [] {
8954
willSet { persistedPurchasedProductIds = newValue }

Sources/StoreKitPlus/Validation/ValidatableTransaction.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88

99
import StoreKit
1010

11-
/// This protocol can be implemented by any transaction that
12-
/// can be validated.
13-
///
14-
/// Valid transactions have no revocation date and also have
15-
/// expired expiration date.
11+
/// This protocol can be implemented by any transaction that can be validated.
1612
public protocol ValidatableTransaction {
1713

1814
/// The date, if any, when the transaction expired.
@@ -28,8 +24,7 @@ public extension ValidatableTransaction {
2824

2925
/// Whether or not the transaction is valid.
3026
///
31-
/// A valid transaction has no revocation date, and also
32-
/// has no expiration date that has passed.
27+
/// A valid transaction has no revocation date, and no past expiration date.
3328
var isValid: Bool {
3429
if revocationDate != nil { return false }
3530
guard let date = expirationDate else { return true }

0 commit comments

Comments
 (0)