apple / swift-homomorphic-encryption

Homomorphic Encryption library and applications in Swift
https://swiftpackageindex.com/apple/swift-homomorphic-encryption/documentation/homomorphicencryption
Apache License 2.0
418 stars 30 forks source link

iOS build failed: target platform (12.0) is lower than required minimum platform (13.0) #135

Open pr33ch opened 1 week ago

pr33ch commented 1 week ago

I am trying to use HomomorphicEncryption in my iOS project on Xcode 16.1 with minimum deployment iOS 18.0. After adding the swift-homomorphic-encryption (version 1.0.2) package as a package dependency using Xcode's package manager, I get the following error message when trying to build:

error: The package product 'Crypto' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0 (in target 'HomomorphicEncryption' from project 'swift-homomorphic-encryption')
error: The package product '_CryptoExtras' requires minimum platform version 13.0 for the iOS platform, but this target supports 12.0 (in target 'HomomorphicEncryption' from project 'swift-homomorphic-encryption')

When cloning the repo locally and trying to build it for iOS 18 (also using Xcode 16.1) in isolation without my own project, I get similar error messages, but with other package products requiring a min platform version of 16.0.

As a workaround, I can modify swift-homomorphic-encryption/Package.swift to include iOS(.v18) in package.platforms:

package.platforms = [
    .macOS(.v15), // Constrained by UInt128 support
    .iOS(.v18)
]

The project will then build successfully without the minimum platform version errors (and additional compiler complaints about specific features only being supported in iOS 18). With the above change, I can also successfully build my own project with the cloned repo as a local package dependency. What I'm wondering is:

  1. Is my workaround the right way of fixing the build issue? If so, maybe I could submit a pull request with my change.
  2. If not, what's the deeper underlying issue causing the build failure, and what would be the best way to fix the issue so that I can build my project with the swift-homomorphic-encryption package?
fboemer commented 1 week ago

Hi @pr33ch, thanks for your interest!

Yes, adding .iOS(.v18) would be how to add support for building on iOS.

However, swift-homomorphic-encryption isn't intended to be used for client-side crypto (see https://developer.apple.com/documentation/cryptokit for on-device crypto APIs), so we won't add .iOS(.v18) into the supported platform list at this time.