This project neatly packs OpenSSL into a dynamic framework for iOS and macOS.
Current OpenSSL version used: 4.0.3
You have a few different options:
- Include the OpenSSL.xcodeproj as a dependency in your project. This is what the projects under
Examples/are doing. Doing this means OpenSSL will be compiled alongside your project, including after every clean (building OpenSSL can take a while). - Use a pre-built OpenSSL.xcframework. You can find them under Releases.
In your Package.swift, add OpenSSL as a dependency:
dependencies: [
.package(url: "https://github.com/OuterCorner/OpenSSL", from: "4.0.3")
],Associate the dependency with your target:
targets: [
.target(name: "App", dependencies: ["OpenSSL"])
]Run bash Scripts/create-xcframework.sh with Xcode selected as the active developer directory.
The result is build/OpenSSL.xcframework, including dSYMs, with these slices:
- iOS: arm64 (iOS 17.6 or later)
- iOS Simulator: arm64 and x86_64 (iOS 17.6 or later)
- macOS: arm64 and x86_64 (macOS 14.6 or later)
The first build downloads the OpenSSL source archive from its GitHub release. The scripts build static OpenSSL libraries into the dynamic framework, using built-in providers with dynamic module loading disabled. Bitcode is disabled for current Xcode. Builds reuse the libraries only while the version, options, architectures, SDK, configuration, deployment targets, and build script match. Clean the project to force a rebuild.
The SwiftPM manifest references the ZIP archive attached to the matching GitHub release.
When publishing a release, update its URL and checksum in Package.swift.
After importing the umbrella header:
#import <OpenSSL/OpenSSL.h>You can simply start using OpenSSL APIs as usual.
Byte buffer[128];
int rc = RAND_bytes(buffer, sizeof(buffer));See example projects under Examples/.
This project is licensed under the MIT License - see LICENSE.
Note the underlying OpenSSL library LICENSE still applies when using this project.
The build scripts for this project were based on: