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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 23:51:10  来源:igfitidea点击:

Installing OpenSSL library for Xcode

iosxcodeopensslstatic-libraries

提问by Marko Zadravec

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

我已经在 xcode 中安装了 OpenSSL 以进行收据验证,但它不起作用。

I download openssl.xcodeprojand openssl-1.0.1f. I extract openssl-1.0.1f and add openssl.xcodeprojto my project.

我下载openssl.xcodeprojopenssl-1.0.1f。我提取 openssl-1.0.1f 并添加openssl.xcodeproj到我的项目中。

files in finderinserted openssl.xcodeproj

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

I edit the Header Search Pathto :

我编辑Header Search Path为:

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

I added libcrypto.ain Target Dependenciesunder Build Phases

libcrypto.aTarget Dependencies构建阶段下添加

and added libcrypto.ain Link Binary With Libraries

并增加libcrypto.aLink 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

enter image description here

在此处输入图片说明

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

最后,将多架构库(libcrypto.alibssl.a)添加到您的 Xcode 项目中。它们位于/usr/local/ssl/ios/lib

enter image description here

在此处输入图片说明

回答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.aor libssl.a. But the same applies to all libraries.

我使用如下图所示的绝对路径,因为 Crypto++、OpenSSL 等安装在/usr/local. 下图是我手头的 Crypto++ 屏幕截图,而不是 OpenSSLlibcrypto.alibssl.a. 但同样适用于所有图书馆。

enter image description here

在此处输入图片说明