SKProductsRequest 在 Xcode 12 GM 在 UI 测试和 SKTestSession 中失败
SKProductsRequest fails in Xcode 12 GM in UI Tests and SKTestSession
当我在 Xcode 12 GM 中 运行 SKProductsRequest
从 UI 测试会话时,它总是失败并出现此错误:
Error Domain=SKErrorDomain Code=0 "UNKNOWN_ERROR" UserInfo={NSLocalizedDescription=UNKNOWN_ERROR, NSUnderlyingError=0x600003d30f30 {Error Domain=ASDErrorDomain Code=507 "Error decoding object" UserInfo={NSLocalizedDescription=Error decoding object, NSLocalizedFailureReason=Attempted to decode store response}}}
我尝试将 SKTestSession
与有效的 .storekit
配置文件一起使用,但没有帮助。虽然在我的单元测试中这与 SKTestSession
.
一起工作正常
有没有办法在 Xcode 12 GM 的 UI 测试中测试商店?或者 SKTestSession
只能在单元测试中使用?
所以经过几天的挖掘,我似乎找到了使它工作的方法。您只需要在应用程序启动 运行ning SKProductsRequest
之前添加一些延迟。我只为 UI 测试设置了 5 秒的延迟——就是这样!现在我的请求有效了!
这是向 运行 请求无错误所需的行:
// Wait for StoreKitTest
Thread.sleep(forTimeInterval: 5)
// Start request
request.start()
当我在 Xcode 12 GM 中 运行 SKProductsRequest
从 UI 测试会话时,它总是失败并出现此错误:
Error Domain=SKErrorDomain Code=0 "UNKNOWN_ERROR" UserInfo={NSLocalizedDescription=UNKNOWN_ERROR, NSUnderlyingError=0x600003d30f30 {Error Domain=ASDErrorDomain Code=507 "Error decoding object" UserInfo={NSLocalizedDescription=Error decoding object, NSLocalizedFailureReason=Attempted to decode store response}}}
我尝试将 SKTestSession
与有效的 .storekit
配置文件一起使用,但没有帮助。虽然在我的单元测试中这与 SKTestSession
.
有没有办法在 Xcode 12 GM 的 UI 测试中测试商店?或者 SKTestSession
只能在单元测试中使用?
所以经过几天的挖掘,我似乎找到了使它工作的方法。您只需要在应用程序启动 运行ning SKProductsRequest
之前添加一些延迟。我只为 UI 测试设置了 5 秒的延迟——就是这样!现在我的请求有效了!
这是向 运行 请求无错误所需的行:
// Wait for StoreKitTest
Thread.sleep(forTimeInterval: 5)
// Start request
request.start()