jedisct1 / libsodium

A modern, portable, easy to use crypto library.
https://libsodium.org
Other
12.06k stars 1.72k forks source link

Fixed xcframework build for iOS 11 and later #1361

Closed nikinapi closed 3 months ago

nikinapi commented 3 months ago

In iOS 11 and later, all apps use the 64-bit architecture.

This pull request aims to fix build errors when IOS_VERSION_MIN is set to 11.0 or higher. For example clang will fail to produce a binary even in the following (simplified) scenario:

> clang -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator17.4.sdk -mios-simulator-version-min=15.0 test.c
clang: error: invalid iOS deployment version '-mios-simulator-version-min=15.0', iOS 10 is the maximum deployment target for 32-bit targets [-Winvalid-ios-deployment-target]

To make this work I've conditionally excluded armv7 and armv7s from "make" step and from "lipo" step based on iOS deployment version. The same is done to i386 in iOS Simulator.

I consider a simple check to be sufficient: 32-bit architectures are included only if major version component is less than 11.

As a minor improvement, I suggest using OS_VERSION_MIN as the default value for the corresponding OS_SIMULATOR_VERSION_MIN, Apple developer tools default to this behavior too.