13

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.

files in finder inserted 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 ?

jww
  • 97,681
  • 90
  • 411
  • 885
Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97
  • possible duplicate of [how to add an existing framework in Xcode 5](http://stackoverflow.com/questions/19337890/how-to-add-an-existing-framework-in-xcode-5) – jww Mar 27 '14 at 19:27

2 Answers2

17

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:

enter image description here

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

enter image description here

jww
  • 97,681
  • 90
  • 411
  • 885
  • in `/usr/local/` I have maps : bin, etc, include, lib, man, Qt, sbin, share, textlive. Do you mean to create new file named `ssl`, but then libcrypto.a and libssl.a would not be there. – Marko Zadravec Mar 27 '14 at 21:27
  • Do a `mkdir -p /usr/local/ssl/ios`. Then you will have it. – jww Mar 27 '14 at 21:35
  • mkdir: /usr/local/ssl/ios: Permission denied – Marko Zadravec Mar 27 '14 at 21:38
  • I would be more than happy if You could show me how to make .a or .framework from .tar.gz because after that I have another lib te extract (asn1c.tar.gz). :D But it this field (and terminal in general) I don't have much experience so be patient and go slow. I really appreciate your time. – Marko Zadravec Mar 27 '14 at 21:42
  • See the various scripts provided with the iOS tarball. That's what I use to build them. `build-all.sh` calls the other scripts in turn for a particular platform. The other scripts set the environment and then invoke `config`, `make`, etc. Your mileage may vary for `asn1c.tar.gz`. – jww Mar 27 '14 at 21:45
  • "... permission denied... " - `sudo mkdir -p /usr/local/ssl/ios`. – jww Mar 27 '14 at 21:47
  • I try `build-all-for-ios.sh` but it gives me : `**************************************** sed: Configure: No such file or directory sed: Makefile.org: No such file or directory sed: Makefile.org: No such file or directory sed: Makefile.org: No such file or directory **************************************** iPhoneSimulator, -i386 CONFIG_OPTIONS=no-asm no-shared --openssldir=/usr/local/ssl/ios build-all-for-ios.sh: line 42: ./config: No such file or directory make: *** No rule to make target `clean'. Stop. cp: ./libcrypto.a: No such file or directory . make:***No rule to make target clean.Stop.` – Marko Zadravec Mar 27 '14 at 22:30
  • In the middle is more but I couldn't paste all of it – Marko Zadravec Mar 27 '14 at 22:30
  • You should ask another question since this is different from your original question. – jww Mar 27 '14 at 22:31
  • I posted new question pleas look and answer – Marko Zadravec Mar 27 '14 at 22:55
  • I want to use openssl in swift , but getting error . Please suggest it , How to configured openssl with swift. – Vipulk617 Oct 14 '15 at 12:14
  • In recent versions of Xcode, putting the location in User Search Path results in errors about using angled brackets instead of quotes for the filenames in #include statements. Do what the answer says, but put the location in Header Search Paths instead. – Nick Apr 03 '18 at 13:57
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.

enter image description here

Community
  • 1
  • 1
jww
  • 97,681
  • 90
  • 411
  • 885
  • My problem is that I have openSll.xcodeproj, and openSLL.tar.gz. If I have openSll.framework I would know what to do. – Marko Zadravec Mar 27 '14 at 20:14
  • 1
    I don't know what `openSll.xcodeproj` is. `openssl-1.0.N.tar.gz` is the source code. Is that what you have? If so, you need to unpack, build, and install it. – jww Mar 27 '14 at 20:16
  • OK, how to build and install it. I am new at this stuff and I will be really thankfull if you could help me. – Marko Zadravec Mar 27 '14 at 20:28
  • 1
    See [Compilation and Installation](http://wiki.openssl.org/index.php/Compilation_and_Installation) on the OpenSSL wiki. There's also a bunch of `INSTALL.` readme's in the root of the source code. The 5 second fly-by: `./config; make all; sudo make install`. You'll then find it in `/usr/local/ssl`. – jww Mar 27 '14 at 20:31
  • in terminal in navigate to file where openssl-1.0.N.tar.gz is located and write your script. It says make: *** [links] Error 1 making all in crypto... /bin/sh: /Applications/Xcode: No such file or directory make: *** [build_crypto] Error 1 Password: and I dont know whitch password I should write. – Marko Zadravec Mar 27 '14 at 20:56
  • You have to cross-compile OpenSSL for iOS after setting your environment (my bad, I forgot to mention it). See the answer below. – jww Mar 27 '14 at 20:59
  • I am using openssl in swift , but getting error . Please suggest it , How to configured openssl with swift. – Vipulk617 Oct 14 '15 at 12:13