Mac Catalyst and OpenSSL

Hi folks,

I'm currently implementing In-App purchase into a Mac Catalyst app, and facing troubles linking to static OpenSSL libraries.

Currently - as in other projects - I'm using a 3rd party tool to implement receipt validation (Receigen), which uses static OpenSSL libraries. These need to be built with a corresponding target (x86_64-apple-ios13.0-macabi?), but so far I wasn't able to compile / link the sources using the build-libssl.sh script from https://github.com/x2on/OpenSSL-for-iPhone.

Unfortunately I a newbie when it comes to building OpenSSL from sources with individual configs. Can anyone point my to some information ... all I found on SO were references to the mentioned target and GitHub repository.

Did anyone of you integrate OpenSSL (or even Receigen) in a Mac Catalyst app ... and how? Maybe it's only me over-complicating things.

Any help is appreciated, Mattes

Accepted Reply

The OpenSSL libraries librypto.a and libssl.a cannot be defined as conditionally being linked: Due to the same names Xcode is only reflecting one platform version in its build phases, and it is not possible to define them platform specific. The solution is to combine these libraries into an XCFramework, so the right architecture for a build target is used automatically.

I've done this using <https://github.com/balthisar/openssl-xcframeworks/releases> ... actually I downloaded the binaries (although they could be built using the sources / scripts in the GitHub repo).

I still had to add OpenSSL header files (and their header search path) as the dynamically generated Receigen file cannot include the frameworks headers.

So my project runs on iOS simulator, iOS device and Mac Catalyst, and I "only" need to figure out the receipt validation thing...

Greetings, Mattes

Replies

Following these instructions I was at least able to have my project build with Mac Catalyst and OpenSSL:
  1. Edit "Configurations/main-10.conf" to add the line "CFLAGS => add("-target x8664-apple-ios13.0-macabi")," into the "darwin64-x8664-cc" section

  2. Run "./Configure darwin64-x86_64-cc -shared"

  3. Run "make clean"

  4. Run "make"

  5. Copy libcrypto.a & libssl.a into the library search path, as already used before for iOS targets

  6. Copy include/internal and include/openssl into the (recursive) header search path, as already used before for iOS targets

The project compiles, links and can be run ... I still need to figure out how to conditionally use the libraries only when linking to Mac Catalyst and not for iOS.

Unfortunately receipt validation still fails, assuming because of different paths in the app bundle? I will post a different question addressing this topic.

So one step forward and the next challenge identified, Mattes





The OpenSSL libraries librypto.a and libssl.a cannot be defined as conditionally being linked: Due to the same names Xcode is only reflecting one platform version in its build phases, and it is not possible to define them platform specific. The solution is to combine these libraries into an XCFramework, so the right architecture for a build target is used automatically.

I've done this using <https://github.com/balthisar/openssl-xcframeworks/releases> ... actually I downloaded the binaries (although they could be built using the sources / scripts in the GitHub repo).

I still had to add OpenSSL header files (and their header search path) as the dynamically generated Receigen file cannot include the frameworks headers.

So my project runs on iOS simulator, iOS device and Mac Catalyst, and I "only" need to figure out the receipt validation thing...

Greetings, Mattes
Not sure if this would help, but this build script now adds Mac Catalyst libraries. It creates separate Catalyst, iOS, iOS-simulator and MacOS static binaries of OpenSSL along with libcurl and nghttp2: https://github.com/jasonacox/Build-OpenSSL-cURL

Run the openssl-build.sh from the openssl folder.