简体   繁体   中英

Installing OpenSSL library for Xcode

I have installed OpenSSL in xcode for receipt validation, but it doesn't work.

I download openssl.xcodeproj and openssl-1.0.1f . I extract openssl-1.0.1f and add openssl.xcodeproj to my project.

查找器中的文件插入了openssl.xcodeproj

I edit the Header Search Path to :

 /Users/marko/Documents/Razvoj/BIView\ Mobile\ New\ Version/openssl/include/openssl

I added libcrypto.a in Target Dependencies under Build Phases

and added libcrypto.a in Link Binary With Libraries

as was described in http://atastypixel.com/blog/easy-inclusion-of-openssl-into-iphone-app-projects/ .

But when I build project it stops with error :

clang: error: no such file or directory: '/Users/ .... -bmgslnakszsfovecplbzoslykrxo/Build/Products/Debug-iphoneos/libcrypto.a'

Why ?

OK, how to build and install it....

It might be easier to use a pre-built version of OpenSSL for iOS. You can find one at this Github account . The OpenSSL from that Github are multi-arch. They have ARMv7, ARMv7s, ARM64, and i386. That means they work with devices and simulators.

Download either OpenSSL 1.0.1e or 1.0.1f. Install it in a location like /usr/local/ssl/ios .

Then, add the headers to your Xcode project. They are located in /usr/local/ssl/ios/include :

在此处输入图片说明

Finally, add the multi-arch libs ( libcrypto.a and libssl.a ) to your Xcode project. They are located in /usr/local/ssl/ios/lib :

在此处输入图片说明

You need to add the library as a Framework. See this question: how to add an existing framework in Xcode 5 .

Its OK to add the OpenSSL libraries under Frameworks. Its how things are done under Apple/Xcode.

I use the Absolute Path like in the image below because Crypto++, OpenSSL, etc are installed in /usr/local . The image below is a screen capture I have handy of Crypto++, and not OpenSSL's libcrypto.a or libssl.a . But the same applies to all libraries.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM