StoreKitTest:请求产品错误域=ASDErrorDomain 代码=950“未处理的异常”
Posted
技术标签:
【中文标题】StoreKitTest:请求产品错误域=ASDErrorDomain 代码=950“未处理的异常”【英文标题】:StoreKitTest : Request product error Domain=ASDErrorDomain Code=950 "Unhandled exception" 【发布时间】:2021-01-12 16:40:12 【问题描述】:我正在尝试使用新的 (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($0.productIdentifier))
expectation?.fulfill()
func requestDidFinish(_ request: SKRequest)
print("DidFinishh")
func request(_ request: SKRequest, didFailWithError error: Error)
print(error)
【问题讨论】:
【参考方案1】:我找到了错误的来源:
在我的测试目标中,在General
中,我删除了Host Application
,因为我不希望应用程序编译并取消选中Allow testing Host Application APIs
。
看来StoreKitTest需要这个设置,但错误实在是不清楚!
【讨论】:
以上是关于StoreKitTest:请求产品错误域=ASDErrorDomain 代码=950“未处理的异常”的主要内容,如果未能解决你的问题,请参考以下文章
错误:错误域=NSURLErrorDomain 代码=-1001“请求超时。”