Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding openSSL to Swift OS X project for receipt validation

Tags:

macos

swift

I am trying to include OpenSSL in a Swift OS X project for receipt validation.

I have successfully built the necessary OpenSSL header and library files. I have added them to my project, but in doing so was not prompted to create a bridging header file. I have created the bridging header file manually with #import for each of the openssl header files. In the project build setting, I have set the objective C bridging header under "swift compiler - code generation" to my bridging header. I have generated the ans1c files for the payload format as described in the receipt validation programming guide: "Listing 1-1 ASN.1 definition of the payload format" and added them to my bridging header.

I get numerous compile errors when I build, mainly for unknown type names in the openSSL header files which I would have thought would be defined in the ans1c header files, but they aren't. I am also getting an error "Failed to import bridging header... (my bridging header file)".

I am running out of ideas, and may have to abandon openSSL for receipt validation. If anyone knows what I am doing wrong, or if you have an alternate method for doing validation, I would love to hear it. My app will have IAP, so it seems I would need some way of checking the receipt.

like image 736
jbaraga Avatar asked Apr 14 '15 14:04

jbaraga


1 Answers

I have finally figured out the source of the compiler errors. XCode is very picky about where the openssl headers are. If I link directly to the header directory entitled "openssl" I get the compiler errors. If I link to the parent folder entitled "include", no errors!

I do not understand this behavior, but at least now I have a solution. Thanks to the instructions on Receigen for adding OpenSSL as a static library, which I finally followed precisely, I was able to discover the source of the error.

like image 166
jbaraga Avatar answered Oct 06 '22 14:10

jbaraga