Un-understandable error thrown when calling Product.products(for:))

Hi,

Whenever trying to call Product.products(for: list) where list contains ids of my subscriptions, I get the following error. I can't seem to catch this error regardless of how i try to implement do/catch, and it only happens on real IDS, if i use an ID that doesn't exist, then it just returns an empty list and doens't crash.

I haven't deployed my app yet, and it's my first app, so I'm not sure if it may be an issue with the subscriptions not being approved yet. I do have all of my agreements signed / bank accounts setup, so i'm not sure.

libswiftCore.dylib`swift_willThrow:
->  0x1a10b9f58 <+0>:  pacibsp 
    0x1a10b9f5c <+4>:  str    x19, [sp, #-0x20]!
....

@MainActor
class PurchaseManager: ObservableObject {

    private let productIds = ["00"]

    @Published
    private(set) var products: [Product] = []
    private var productsLoaded = false

    func loadProducts() async throws {
        guard !self.productsLoaded else { return }
        self.products = try await Product.products(for: ["com.one_dollar"])
        self.productsLoaded = true
        print("Products")
        print(self.products)

    }
 ....
}

where i'm calling it:

struct AmountSelectionView: View {
    @EnvironmentObject var purchaseManager: PurchaseManager  // Add this line
    var body: some View {
        HStack(spacing: 16) {
...
        }
        .padding()
        .padding(.top, -30)
        .task {
            Task {
                print("Loading Products")
                do {
                    try await purchaseManager.loadProducts()
                } catch {
                    print("error")
                    print(error)
                }
            }
        }
    }

}
Answered by brett_a in 802866022

This ended up resolving on its own the next day without any additional action on my end.

Could you show the code of Product structure? If the error is there, it will help to see the code.

Accepted Answer

This ended up resolving on its own the next day without any additional action on my end.

It looks like you may have Swift error breakpoints enabled in Xcode. This causes your code to pause whenever a Swift error is thrown. It's not the same as a crash, and you can continue your program the same as you'd continue from any other breakpoint.

Swift frameworks like StoreKit may recover from Swift errors internally. Even if the error is eventually recovered from, and your StoreKit API call succeeds, you could end up pausing at a Swift error breakpoint internal to StoreKit code. You can just continue your program in these cases, or temporarily disable Swift error breakpoints to avoid disruptions.

For more information, see Pause on an uncaught Swift error or Objective-C exception.

Un-understandable error thrown when calling Product.products(for:))
 
 
Q