Amid mounting frustration following many failed attempts and Google searches, I successfully built openSSL 1.1.1g for Catalyst, compiled my project, linked openSSL and launched the app on my Mac by doing the following:
- I used the same directory in to which I had previously extracted and built openSSL for IOS.
- Following instructions here, I edited
<openSSL directory>/Configurations/10-main.conf
. Scrolling down to the "darwin64-x86_64-cc"
section, I added a second CFLAGS
line:
CFLAGS => add("-target x86_64-apple-ios13.0-macabi"),
In the openSSL directory, execute ./Configure darwin64-x86_64-cc -shared
Note that I've seen several other versions of this Configure statement, some with many more options. This command worked for me, but I'm not sure what all the other variations do. You may want to research this further.
Execute make clean
to clear all the objects from the prior IOS build
Execute make
This successfully built openSSL.
In Xcode, under -> General -> "Frameworks, Libraries and Embedded Content" I removed both libcrypto.a and libssl.a this was a critical step
Switching tabs to Build Phases -> Link Binary With Libraries, verify both archives are removed from this section as well. (It appeared that removing them in step 5 also cleared them in step 6, but I'm not certain).
Back on General -> Frameworks, click the +
to add new entries, select "add other" in the lower left corner of the popup window, then provide the path to the newly built libcrypto.a. Repeat for libssl.a
Delete the derived data in a terminal window (I'm not certain this was necessary, but did it out of an abundance of caution):
cd ~/Library/Developer/Xcode
mv DerivedData DerivedData.old
- Build the project in Xcode. This successfully completed.
Steps 5-7 turned out to be critical. Even though I moved and/or completely replaced the prior libraries, when I tried to build in Xcode I would get linker errors that I was building for MacOS Catalina but trying to link something built for MacOS x86.