Installing OpenSSL library for Xcode
Solution 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
:
Solution 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.
Marko Zadravec
Updated on July 09, 2022Comments
-
Marko Zadravec almost 2 years
I have installed OpenSSL in xcode for receipt validation, but it doesn't work.
I download
openssl.xcodeproj
andopenssl-1.0.1f
. I extract openssl-1.0.1f and addopenssl.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
inTarget Dependencies
under Build Phasesand added
libcrypto.a
inLink 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 ?
-
Marko Zadravec over 10 yearsMy problem is that I have openSll.xcodeproj, and openSLL.tar.gz. If I have openSll.framework I would know what to do.
-
jww over 10 yearsI 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. -
Marko Zadravec over 10 yearsOK, how to build and install it. I am new at this stuff and I will be really thankfull if you could help me.
-
jww over 10 yearsSee Compilation and Installation on the OpenSSL wiki. There's also a bunch of
INSTALL.<platform>
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
. -
Marko Zadravec over 10 yearsin 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.
-
jww over 10 yearsYou have to cross-compile OpenSSL for iOS after setting your environment (my bad, I forgot to mention it). See the answer below.
-
Marko Zadravec over 10 yearsin
/usr/local/
I have maps : bin, etc, include, lib, man, Qt, sbin, share, textlive. Do you mean to create new file namedssl
, but then libcrypto.a and libssl.a would not be there. -
jww over 10 yearsDo a
mkdir -p /usr/local/ssl/ios
. Then you will have it. -
Marko Zadravec over 10 yearsmkdir: /usr/local/ssl/ios: Permission denied
-
Marko Zadravec over 10 yearsI 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.
-
jww over 10 yearsSee 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 invokeconfig
,make
, etc. Your mileage may vary forasn1c.tar.gz
. -
jww over 10 years"... permission denied... " -
sudo mkdir -p /usr/local/ssl/ios
. -
Marko Zadravec over 10 yearsI 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 over 10 yearsIn the middle is more but I couldn't paste all of it
-
jww over 10 yearsYou should ask another question since this is different from your original question.
-
Marko Zadravec over 10 yearsI posted new question pleas look and answer
-
Vipulk617 over 8 yearsI am using openssl in swift , but getting error . Please suggest it , How to configured openssl with swift.
-
Vipulk617 over 8 yearsI want to use openssl in swift , but getting error . Please suggest it , How to configured openssl with swift.
-
Nick about 6 yearsIn 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.