简体   繁体   中英

How to include OpenSSL on an iOS project in a way that works

I have followed all tutorials on the web to do this. Everything works fine, up to the point I add this line on a class:

#import <openssl/pkcs7.h>

Then I have this error 'openssl/pkcs7.h' file not found .

How bad can Xcode be? I drag every file to Xcode and the files cannot be found?

This is the structure I have now:

  1. the app has 2 targets, openSSL must be installed on the iPad one?
  2. I have used this script
  3. the iPad target is on the following path relative to the base directory path: "Myapp ipad"
  4. The script generated two files "libcrypto.a" and "libssl.a". Both files are inside a directory named "lib" inside "Mhapp ipad" (= "Myapp ipad/lib")
  5. The script also generated an "include/openssl" directory with a lot of files. I have dragged it to "Myapp ipad". So it is now at "MyApp ipad/include"

How do I fill the search paths, library search paths, whatever to make this work?

最简单的解决方案是使用 CocoaPods - 有一个OpenSSL pod ...

Make sure you have set the paths:

在此处输入图片说明

In the Header Search Path I use ${SRCROOT}/macOS and set it to Recursive . Why not specify the directory and non Recursive ? I searched for bugs related to XCode 11 and Header Search Path . If I set the full path it did not work. If I set it to ${SRCROOT} and recursive it failed. Odd?

The same Library Search Path - the path to the .a files - you could just say ${SRCROOT} but this can get you in trouble if you have multuple .a files for different architectures in the same project. This threw up linking errors for me so I used ${SRCROOT}/macOS .

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