After getting excited about 2019's WWDC announcements, I tried compiling my existing iOS app against the MacOS using Xcode 11.0 beta. Unfortunately, it didn't go as expected.
Xcode says my static library is built for < unknown > architecture:
Building for UIKit for Mac, but the linked library 'libssl.a' was built for < unknown >. You may need to restrict the platforms for which this library should be linked in the target editor.
But when I check my static libs, I can see they do contain the desired architecture x86_64
:
I believe this issue may be related to an Xcode Beta bug. Does anyone have thoughts on this?
git clone [email protected]:marcelosalloum/OpenSSL-for-iPhone.git --branch feature/mac-catalyst && \
cd OpenSSL-for-iPhone && \
./build-libssl.sh --archs="MacOSX_x86_64 i386 arm64 armv7s armv7"
According to edford, Apple's software engineer, we need to build our binaries for the iOS platform, targeting MacOSX
and use the CFLAG
-target x86_64-apple-ios13.0-macabi
. There is a very enlightening discussion here: https://forums.developer.apple.com/message/362577.
I've forked OpenSSL-for-iPhone here and implemented MacCatalyst support in the branch feature/mac-catalyst
.
You can build it for MacCatalyst
either by specifying archs
or targets
:
--archs
, for OpenSSL <= 1.0.2:git clone [email protected]:marcelosalloum/OpenSSL-for-iPhone.git --branch feature/mac-catalyst && \
cd OpenSSL-for-iPhone && \
./build-libssl.sh --archs="MacOSX_x86_64 i386 arm64 armv7s armv7" --version="1.0.2l"
--targets
for OpenSSL >= 1.1.0git clone [email protected]:marcelosalloum/OpenSSL-for-iPhone.git --branch feature/mac-catalyst && \
cd OpenSSL-for-iPhone && \
./build-libssl.sh --targets="ios-sim-cross-i386 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 mac-catalyst-x86_64" --version="1.1.0"
All the above solutions didn't work for me, so I went on and tried to fix it for my system running Mac OSX 10.15.4.
In my case this is where the above solutions stopped working for me:
no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.4.sdk' [-Wmissing-sysroot]
I read through the build-libssl.sh file noticed that the sdk version was taken by the script using the code:
xcrun -sdk macosx --show-sdk-version
which on my system does return:
10.15.4
Using finder an navigating to the location:
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
did show me there was indeed no MacOSX10.15.4.sdk. There was however a MacOSX10.14.sdk. I did use this knowledge to come up with the following solution:
OpenSSL version <= 1.0 (1.0.2l)
versions <= 1.0 should only use --arch, not --target !
git clone [email protected]:marcelosalloum/OpenSSL-for-iPhone.git --branch feature/mac-catalyst && \
cd OpenSSL-for-iPhone && \
./build-libssl.sh --arch="MacOSX_x86_64 i386 arm64 armv7s armv7 tv_x86_64 tv_arm64" --macosx-sdk=10.15 --version="1.0.2l"
OpenSSL version >= 1.1 (1.1.0) currently not functional
versions >= 1.1 should only use --target, not --arch !
git clone [email protected]:marcelosalloum/OpenSSL-for-iPhone.git --branch feature/mac-catalyst && \
cd OpenSSL-for-iPhone && \
./build-libssl.sh --targets="mac-catalyst-x86_64 ios-sim-cross-i386 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 tvos-sim-cross-x86_64 tvos64-cross-arm64" --macosx-sdk=10.15 --version="1.1.0" -v
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With