I'm trying to unit test my framework calling StoreKit with the new (iOS 14) StoreKitTest and I'm getting this error when I fetch products :
Error Domain=SKErrorDomain Code=0 "UNKNOWN_ERROR" UserInfo={NSLocalizedDescription=UNKNOWN_ERROR, NSUnderlyingError=0x7fab74623870 {Error Domain=ASDErrorDomain Code=950 "Unhandled exception" UserInfo={NSLocalizedDescription=Unhandled exception, NSLocalizedFailureReason=An unknown error occurred}}}
This is my code :
import XCTest
import StoreKitTest
class FrutaTests: XCTestCase {
var session: SKTestSession!
var request: SKProductsRequest!
var expectation: XCTestExpectation?
override func setUpWithError() throws {
session = try SKTestSession(configurationFileNamed: "Configuration")
}
override func tearDownWithError() throws {
session = nil
}
func testFetchProducts() throws {
let productIdentifiers = Set<String>()
expectation = XCTestExpectation(description: "fetchProducts")
request = SKProductsRequest(productIdentifiers: productIdentifiers)
request.delegate = self
request.start()
wait(for: [expectation!], timeout: 10.0)
}
}
extension FrutaTests: SKProductsRequestDelegate {
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
print(response.products.map({$0.productIdentifier}))
expectation?.fulfill()
}
func requestDidFinish(_ request: SKRequest) {
print("DidFinishh")
}
func request(_ request: SKRequest, didFailWithError error: Error) {
print(error)
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…