[英]Bundle.main.url(forResource: "AppleIncRootCertificate", withExtension: "cer") == nil
In order to set up Receipt-Validation in a Swift
iOS app (using In-App-Purchase
), I am following this tutorial: https://www.raywenderlich.com/9257-in-app-purchases-receipt-validation-tutorial and reading here: Validating Apple Signed the Receipt .为了在
Swift
iOS 应用程序中设置收据验证(使用In-App-Purchase
),我正在学习本教程: https : //www.raywenderlich.com/9257-in-app-purchases-receipt-validation-教程和阅读:验证 Apple 签署了收据。
Here is a problem I have at this point.这是我目前遇到的一个问题。
In the code I have this:在代码中我有这个:
Bundle.main.url(forResource: "AppleIncRootCertificate", withExtension: "cer")
And when I check its value, it is nil.当我检查它的值时,它是零。 Since it is supposed to be used to extract further information, it shoud obviously not be nil.
由于它应该用于提取更多信息,因此它显然不应为零。 The question is: what could be wrong in the code or in some setting to make this nil?
问题是:代码或某些设置中可能有什么问题使此为零?
This is my first time to implement Receipt-Validation, so it may well be that I am missing something basic.这是我第一次实现收据验证,所以很可能我遗漏了一些基本的东西。
I think you probably solved your issue, but this may be useful for someone else on how clearly solve the issue.我认为您可能已经解决了您的问题,但这可能对其他人如何清楚地解决问题有用。 So, if
因此,如果
Bundle.main.url(forResource: "AppleIncRootCertificate", withExtension: "cer")
gives you nil
, you don't have this certificate.给你
nil
,你没有这个证书。 As suggested in comments above, go here and download needed certificate unde the Apple Root Certificates -> Apple Inc. Root Certificate.正如上面评论中所建议的,去这里下载所需的证书,在 Apple Root Certificates -> Apple Inc. Root Certificate 下。
Now you need to add downloaded certificate to your target.现在您需要将下载的证书添加到您的目标。 Move to Build Phases of your target, expand Copy Bundle Resources and press "+" button.
移动到目标的构建阶段,展开复制捆绑资源并按“+”按钮。 Then select "Open Other..." and select certificate.
然后选择“打开其他...”并选择证书。 Check the box "import if needed" or something like that and launch an app.
选中“需要时导入”框或类似内容并启动应用程序。 Now you shouldn't get nil.
现在你不应该得到零。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.