Installing OpenSSL library for Xcode

邮差的信 提交于 2019-12-17 18:38:39

问题


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.

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 ?


回答1:


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:




回答2:


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.



来源:https://stackoverflow.com/questions/22692564/installing-openssl-library-for-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!