未解析的标识符 - SKErrorPaymentCancelled

Unresolved Identifier - SKErrorPaymentCancelled

我昨天更新了 Xcode 7.3 的最新版本 iOS 9.3 和 OSX 10.11.4(包括 Swift 2.2)。

当我构建我的应用程序时,我收到一条错误消息 Use of unresolved identifier 'SKErrorPaymentCancelled' 我用它来检查用户是否取消了付款。我没有对它做任何特别的事情,只是记录它(如下所示)。

private func failedTransaction(transaction: SKPaymentTransaction) {
    print("failedTransaction...")
    if transaction.error!.code == SKErrorPaymentCancelled {
        print("Transaction Cancelled: \(transaction.error!.localizedDescription)")
    }
    else {
        print("Transaction Error: \(transaction.error!.localizedDescription)")
    }
    SKPaymentQueue.defaultQueue().finishTransaction(transaction)
}

我在 Swift 2.2 更新日志中找不到任何说明 StoreKit 中的任何内容已更改的内容。这在我更新之前工作得很好。

还有其他人看到这个问题吗?

从 iOS 9.3 开始,常量 SKErrorPaymentCancelled 已从 SDK 中删除。相反,使用 SKErrorCode.PaymentCancelled 枚举。

有关详细信息,请参阅 StoreKit Changes for Swift page of the iOS 9.3 API Diffs and my canonical Q&A post