OpenSSL CocoaPod and Carthage for iOS and OSX. Complete solution to OpenSSL on iOS and OSX. Package came with precompiled libraries, and include script to build newer version if necessary.
Current version contains binaries build with latest iOS SDK iOS (target 6.0), and latest OSX SDK (target 10.8) for all supported architectures.
- iOS with architectures: armv7, armv7s, arm64 + simulator (x86_64)
- OSX with architectures: x86_64
Apple says: "Although OpenSSL is commonly used in the open source community, OpenSSL does not provide a stable API from version to version. For this reason, although OS X provides OpenSSL libraries, the OpenSSL libraries in OS X are deprecated, and OpenSSL has never been provided as part of iOS."
Latest development version:
pod 'OpenSSL-Universal', :git => 'https://github.com/krzyzanowskim/OpenSSL.git', :branch => :master
Latest stable version:
Latest development version:
github "krzyzanowskim/OpenSSL" "master"
This tutorial assumes you want to:
- Write a C application.
- Use OpenSSL libraries for some crypto operation.
- Use a Mac and Xcode 8+.
- Use CocoaPods and the OpenSSL-Universal pod as an elegant way to stay updated with the latest libraries and headers.
Step 1 - Create your macOS HelloWorld C app
If you have not done this before with Xcode, select
File / New Project / macOS / Command Line Tool. Hit build and run. You just successfully build the default Hello World C project.
Step 2 - Setup Cocoa Pods
Make sure your machine is setup for CocoaPods.
After CocoaPods is setup, open
Terminal and navigate to your project folder and run
After that has completed, type
open -a Xcode Podfile.
Step 3 - get the OpenSSL-Universal pod
pod 'OpenSSL-Universal' inside the podfile.
Save the file.
Terminal and run
After that download completes, make sure to close the C project and open the workspace file that was created.
Step 4 - What is inside of the OpenSSL-Universal pod?
Once this successfully completed, you have now got access to a pre-compiled version of the static OpenSSL libraries and the C header files required to call these functions.
Where can I use OpenSSL-Universal?#
These libraries work for both iOS and MacOS. There are two OpenSSL static libraries;
::Do NOT expect these OpenSSL files to work on every CPU architecture in the world. It is your prerogative to check. Ask yourself, are you trying to write an app for old devices? new devices only? all iOS devices? only macOS?, etc ::
The OpenSSL-Universal Framework is a Fat Binary. That means it supports multiple CPU architectures in a single file.
To understand this, return to
Terminal. Navigate to your OpenSSL-Universal macOS files and run the command
file libcrypto.a This will tell you architecture the file is compiled against
x386. If you tried the iOS OpenSSL-Universal files it would have said
arm64 + Simulators (
You want to ensure Xcode knows;
- Where the OpenSSL static libraries are located.
- Where the OpenSSL header files are located for the C include statements.
Inside your workspace, go to the Target (not the Project). The Target is the C app that is produced after a successful build. Select
Link Binary With Libraries. Select
+and navigate to the static OpenSSL libraries that was included in the framework. The magical result was, your
Library Search Pathswere populated without you typing anything. Now go to the Target. In
Build Settingsset the
Always Search User Pathsto
Yes. Then add a new entry to the
User Header Search Paths. This should be the location of the OpenSSL header files that were included in OpenSSLUniversal.