StoreKitTest : 请求产品错误 Domain=ASDErrorDomain Code=950 "Unhandled exception"
StoreKitTest : Request product error Domain=ASDErrorDomain Code=950 "Unhandled exception"
我正在尝试使用新的 (iOS 14) StoreKitTest 对调用 StoreKit 的框架进行单元测试,但在获取产品时出现此错误:
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}}}
这是我的代码:
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({[=12=].productIdentifier}))
expectation?.fulfill()
}
func requestDidFinish(_ request: SKRequest) {
print("DidFinishh")
}
func request(_ request: SKRequest, didFailWithError error: Error) {
print(error)
}
}
我找到了错误的来源:
在我的测试目标中,在 General
中,我删除了 Host Application
,因为我不希望应用程序编译并取消选中 Allow testing Host Application APIs
.
StoreKitTest好像需要这个设置,但是报错实在是不清楚!
我正在尝试使用新的 (iOS 14) StoreKitTest 对调用 StoreKit 的框架进行单元测试,但在获取产品时出现此错误:
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}}}
这是我的代码:
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({[=12=].productIdentifier}))
expectation?.fulfill()
}
func requestDidFinish(_ request: SKRequest) {
print("DidFinishh")
}
func request(_ request: SKRequest, didFailWithError error: Error) {
print(error)
}
}
我找到了错误的来源:
在我的测试目标中,在 General
中,我删除了 Host Application
,因为我不希望应用程序编译并取消选中 Allow testing Host Application APIs
.
StoreKitTest好像需要这个设置,但是报错实在是不清楚!