SKTestSession.setSimulatedError does not work - Products load successfully despite error configuration

Description

I'm attempting to test error handling in my StoreKit implementation using SKTestSession.setSimulatedError(), but it doesn't trigger any errors. All StoreKit APIs (.loadProducts, .purchase, .appTransaction) succeed despite error simulation being configured before API calls.

According to Apple's documentation, setSimulatedError(_:forAPI:) should cause the specified API to throw an error, but this doesn't happen in my testing environment.

Background / Known issue

I found a previous forum discussion: "SKTestSession.setSimulatedError() not working for .loadProducts API in iOS 26.2" which mentioned this was a bug in iOS 26.2 and was supposedly fixed in iOS 26.3.

However, I'm experiencing the same issue in my current environment (Xcode 26.6 / iOS 26.5), which suggests either:

  1. The bug has regressed, or
  2. There's a different underlying issue, or
  3. I'm missing something in my implementation

I wanted to report this to confirm whether this is still a known issue or if additional steps are needed.

Environment
  • Xcode: 26.6
  • Test Environment: iOS Simulator - iPhone 17 Pro(26.5)
  • Testing Framework: XCTest
  • StoreKitTest Framework: Included in Xcode
Code
Unit test code
import XCTest
import StoreKit
import StoreKitTest

final class StoreKitErrorTests: XCTestCase {

    func test_LoadProducts_SetSimulatedError() async throws {
        // Arrange
        let session = try SKTestSession(configurationFileNamed: "storekit")
        session.clearTransactions()
        session.disableDialogs = true
        
        // Set simulated error for loadProducts API
        try await session.setSimulatedError(
            .generic(.unknown),
            forAPI: .loadProducts
        )
        
        // Act - Attempt to load products
        do {
            let products = try await Product.products(for: ["com.example.app.testproduct"])
            
            // This line executes - products were loaded successfully
            print("[TEST] FAIL: Loaded \(products.count) products")
            XCTFail("setSimulatedError did not work - products loaded successfully")
        } catch {
            // This should execute, but it doesn't
            print("[TEST] PASS: Error was thrown")
        }
    }
}
.storekit file

Note: Showing only the product definition. File also contains settings and version info.

{
  "products" : [
    {
      "displayPrice" : "1.23",
      "familyShareable" : false,
      "internalID" : "5AE6F98A",
      "localizations" : [
        {
          "description" : "Test app",
          "displayName" : "LsStorekit",
          "locale" : "en_US"
        }
      ],
      "productID" : "com.example.app.testproduct",
      "referenceName" : "LsStorekit",
      "type" : "NonConsumable"
    }
  ]
}
Expected Behavior

The Product.products(for:) call should throw an error because setSimulatedError(.generic(.unknown), forAPI: .loadProducts) was called before the API invocation.

The test should:

  1. Configure the simulated error
  2. Attempt to load products
  3. Catch an error in the catch block
  4. Test passes with: "[TEST] PASS: Error was thrown"
Actual Behavior

Products are loaded successfully despite the error simulation:
• The do block completes without throwing
• 1 product is returned from Product.products(for:)
• XCTFail() is called, indicating the error simulation didn't work
• Test fails with: "[TEST] FAIL: Loaded 1 products"

Console Output

[TEST] FAIL: Loaded 1 products

Additional Testing

I've tested setSimulatedError with multiple APIs, and all show the same behavior:

APIError configurationResult
.loadProducts.generic(.unknown)No error thrown
.purchase.generic(.unknown)No error thrown
.appTransaction.generic(.unknown)No error thrown
.appStoreSync.generic(.unknown)No error thrown
What I've Already Tried

• Calling setSimulatedError before app launch (in UI tests)
• Calling setSimulatedError after app launch but before API calls
• Using different error types (.generic(.unknown), .generic(.networkError(...)))
• Testing in both Unit Tests and UI Tests
• Using different APIs (.loadProducts, .purchase, .appTransaction)
• Clearing transactions and resetting session state
• Verifying the .storekit file is correctly loaded (products load successfully)
• Running the app first (⌘R) to ensure StoreKit configuration is registered with the StoreKit daemon - This was necessary to fix an initial issue where products weren't loading at all

Questions
  1. Is this a known limitation of SKTestSession.setSimulatedError()?
  2. Are there additional steps required to make error simulation work?
  3. Is there an alternative approach to test StoreKit error handling?
  4. Does this work in specific Xcode/iOS SDK versions only?

Any guidance would be greatly appreciated. I need to test error handling in my StoreKit implementation, but cannot find a way to simulate errors reliably.