iosswiftopensslreceipt-validation

Use of undeclared type 'PKCS7' (Receipt-Validation/OpenSSL)


To set up Receipt-Validation in my iOS app, I am now following this tutorial: https://www.raywenderlich.com/9257-in-app-purchases-receipt-validation-tutorial and reading at this point: Loading the Receipt.

While reading and attempting to understand what is going on I also try to integrate the code in my own app, by doing so getting a hands-on understanding of the process.

Here is one problem I am hitting at this moment:

On this line of code:

private func loadReceipt() -> UnsafeMutablePointer<PKCS7>? {

I get this error message:

Use of undeclared type 'PKCS7'

After searching the net and trying a few things, I guess it is related to the use of the use of the ReceiptVerifier-Bridging-Header.h file. But I am not sure how to set it in the project.

I will be glad if anyone has some tip allowing me to move forward. Thanks in advance!

In case this can be useful, here is the meaningful contents of the bridging header file (ReceiptVerifier-Bridging-Header.h):

#import <openssl/pkcs7.h>
#import <openssl/objects.h>
#import <openssl/evp.h>
#import <openssl/ssl.h>
#import <openssl/asn1_locl.h>

Solution

  • The problem is that I had simply copied the bridge-header file, without doing the proper setting as explained here: https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_objective-c_into_swift