ios 为 Xcode 安装 OpenSSL 库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22692564/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing OpenSSL library for Xcode
提问by Marko Zadravec
I have installed OpenSSL in xcode for receipt validation, but it doesn't work.
我已经在 xcode 中安装了 OpenSSL 以进行收据验证,但它不起作用。
I download openssl.xcodeproj
and openssl-1.0.1f
. I extract openssl-1.0.1f and add openssl.xcodeproj
to my project.
我下载openssl.xcodeproj
和openssl-1.0.1f
。我提取 openssl-1.0.1f 并添加openssl.xcodeproj
到我的项目中。
I edit the Header Search Path
to :
我编辑Header Search Path
为:
/Users/marko/Documents/Razvoj/BIView\ Mobile\ New\ Version/openssl/include/openssl
I added libcrypto.a
in Target Dependencies
under Build Phases
我libcrypto.a
在Target Dependencies
构建阶段下添加
and added libcrypto.a
in Link Binary With Libraries
并增加libcrypto.a
在Link Binary With Libraries
as was described in http://atastypixel.com/blog/easy-inclusion-of-openssl-into-iphone-app-projects/.
如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 ?
为什么 ?
回答by jww
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.
使用适用于 iOS 的预构建版本的 OpenSSL 可能更容易。您可以在此Github 帐户中找到一个。该 Github 中的 OpenSSL 是多架构的。他们有 ARMv7、ARMv7s、ARM64 和 i386。这意味着它们可以与设备和模拟器一起使用。
Download either OpenSSL 1.0.1e or 1.0.1f. Install it in a location like /usr/local/ssl/ios
.
下载 OpenSSL 1.0.1e 或 1.0.1f。将其安装在类似的位置/usr/local/ssl/ios
。
Then, add the headers to your Xcode project. They are located in /usr/local/ssl/ios/include
:
然后,将标头添加到您的 Xcode 项目中。它们位于/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
:
最后,将多架构库(libcrypto.a
和libssl.a
)添加到您的 Xcode 项目中。它们位于/usr/local/ssl/ios/lib
:
回答by jww
You need to add the library as a Framework. See this question: how to add an existing framework in Xcode 5.
您需要将库添加为框架。看到这个问题: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.
可以在 Frameworks 下添加 OpenSSL 库。它是如何在 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.
我使用如下图所示的绝对路径,因为 Crypto++、OpenSSL 等安装在/usr/local
. 下图是我手头的 Crypto++ 屏幕截图,而不是 OpenSSLlibcrypto.a
或libssl.a
. 但同样适用于所有图书馆。