Recipe for Building OpenSSL static library for Apple Silicon & Intel?

So to support Apple Silicon in my app I need a fat version OpenSSL for Intel/Arm.

However, I cannot get OpenSSL to build for ARM if I lower the deployment target to an earlier version of macOS before Big Sur.

I was able to make a fat version of OpenSSL by making the ARM half have a deployment target of 10.15, but when added to my project, Xcode spits out warnings about Object files built for a newer macOS version than being linked.

Anyone know the proper procedure to make a backward compatible version (pre-macOS 10.15) of OpenSSL static library and still support M1 natively?

I don't think I'm currently willing to raise the deployment target of my app to 10.15 just to link the OpenSSL library.

Replies

I was able to build an XCFramework of OpenSSL v1.1.1h based on

https://github.com/adib/openssl-xcframeworks/tree/develop/BigSur

for all platforms with fat binaries for all architectures, including:

macOS (x8664, arm64)
iOS Mac Catalyst (x86
64, arm64)
iOS (armv7, arm64)
iOS simulator (x8664, arm64)
tvOS (arm64)
tvOS simulator (x86
64)
watchOS (arm64_32, armv7k)

I'm using it with a macOS deployment target 10.11...

Cheers, Mattes
@MyMattes

Thanks for sharing that repository. I wasn't able to get this to build though. I keep getting the following error:

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool-classic: can't open file: MacOSX10.11-x86_64.sdk/lib/libcrypto.a (No such file or directory)

Do you know where I could be going wrong here?

  • Sorry for not responding so long, I didn't receive any notification about your reply...

    I wasn't facing any issue building a static XCFramework using the mentioned repository. Unfortunately I didn't documented the steps it took, but based on its README I must have used the command line

    ./create-framework.sh xcstatic

    HTH, Mattes

Add a Comment
@MyMattes

iOS (armv7, arm64)
iOS simulator (x8664, arm64)

How are you configuring your project though to pick the right archive based on the platform?

I see that there is "macOS + iOS / macOS / iOS" drop down in "Link Library With Libraries", but it has no option to pick one library for Simulator and another library for device.
  • Sorry for not responding so long, I didn't receive any notification about your reply...

    I'm just referencing the OpenSSL XCFramework in my targets, having Xcode picking the correct architecture. Of course I needed to update the HEADER_SEARCH_PATHS to reflect the framework's location, but that's all.

    Mattes

Add a Comment