简体   繁体   English

Bundle.main.url(forResource: "AppleIncRootCertificate", withExtension: "cer") == nil

[英]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.

相关问题 Bundle.main.url(forResource:“ hello”,withExtension:“ html”)返回nil - Bundle.main.url(forResource: “hello”, withExtension: “html”) is returning nil Bundle.main.path(forResource :)返回nil - Bundle.main.path(forResource:) returns nil URL(fileURLWithPath:Bundle.main.path(forResource:“ ports”,ofType:“ geojson”)!)是零吗? - URL(fileURLWithPath: Bundle.main.path(forResource: “ports”, ofType: “geojson”)!) is nil? Bundle.main.url 找不到文件 - Bundle.main.url cannot find file Bundle.main.path(forResource:ofType:inDirectory:) 返回 nil - Bundle.main.path(forResource:ofType:inDirectory:) returns nil Bundle.main.url 无法找到使用 PropertyListSerialization 保存的 plist - Bundle.main.url is unable to locate plist saved with PropertyListSerialization 核心数据:bundle.main.url 线程 1 致命错误 - Core Data: bundle.main.url Thread 1 fatal error 当目录和文件名正确时,Bundle.main.path(forResource:ofType:inDirectory :)返回nil - Bundle.main.path(forResource:ofType:inDirectory:) returns nil when directory and filename are correct 当应用名称包含“空格”时,Bundle.main.path(forResource:ofType:inDirectory :)返回nil - Bundle.main.path(forResource:ofType:inDirectory:) returns nil when app name contains “space” 为什么Bundle.main.path(forResource:fileName,ofType:“ txt”)总是返回nil? - why does Bundle.main.path(forResource: fileName, ofType: “txt”) always return nil?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM