how to add openssl to a swift project
Asked Answered
B

1

7

I am learning how to add in-app purchase receipt validation to my iOS/OSX projects.

There is a nice overview here and the WWDC14 has good videos on this topic.

Plenty of sample code, but everyone skips one step. How to import the openSSL header. The swift compiler complains that there is no such module.

import Foundation
import StoreKit
import openssl  //no such module ???

I am already stuck before writing one line of code. Where is the openssl framework hiding?

Brynne answered 13/7, 2015 at 10:18 Comment(1)
Check out my answer over here, seems to do the trick: https://mcmap.net/q/1626140/-non-modular-headers-of-openssl-library-when-using-modulemap-for-swift-frameworkLitotes
C
4

There is no OpenSSL module built in. You have to compile it yourself - this is for security so that everyone doesn't implement the exact same security.

Take a look at : https://gist.github.com/foozmeat/5154962 http://www.cvursache.com/2013/08/13/How-To-Build-openssl-For-iOS/

There is a also a cocoapods at http://cocoapods.org/?q=openssl

You should never use a static module provided by someone else. Always build your own.

Apples official explanation here - under OpenSSl - https://developer.apple.com/library/ios/documentation/Security/Conceptual/cryptoservices/GeneralPurposeCrypto/GeneralPurposeCrypto.html

Casiecasilda answered 13/7, 2015 at 10:42 Comment(7)
This script worked for me. github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.shBrynne
I am facing problem in configured openssl in swift project. Please suggest it , How to configured openssl in swift.Caribbean
@Brynne can you send demo application openssl with swift.Caribbean
@vipulk617 No, sorry. I learned that the reason there is no standard module is due to security reasons. Everyone should make their own module to reduce the risk of a security breach. Just look at what Dave posted. You can use that to figure out how to build you own.Brynne
@Brynne I just want to access private content from cloud front using following link forums.aws.amazon.com/thread.jspa?messageID=336955 But not able to use openssl in swift . I just want to know , How to only integrate openssl library in swift not write any code because i tried this library in swift but getting error.Caribbean
Download the openssl source, compile it (there are scripts available for iOS/OSX), include the compiled code as a framework into your xcode project.Brynne
I am using cocoa pod for openssl but getting error when i write #include <openssl/pem.h> in header file. This error is only swift project .Caribbean

© 2022 - 2024 — McMap. All rights reserved.