mirror of
https://github.com/luxfhe/example-ios-demo.git
synced 2026-10-30 18:13:24 +00:00
The rebrand renamed dependencies it does not own. luxfhe/tfhe-rs and luxfhe/torus-ml-extensions are not repositories, torus-ml-extensions is not on PyPI, and a torus_ml_extensions library is not what the script's build of concrete-ml-extensions produces, so neither the server nor the frameworks could build. They name zama-ai/tfhe-rs and concrete-ml-extensions again, and the README says again who built TFHE-rs and Concrete ML. Co-authored-by: Hanzo Dev <[email protected]>
2.5 KiB
2.5 KiB
Compiling app dependencies for iOS and Mac simulator
1. Install Rust
- Install the latest Rust release (currently 1.81.0):
curl https://sh.rustup.rs -sSf | sh
- Install extra target architectures (for iOS devices & iOS simulators running on Apple Silicon Macs):
rustup target add aarch64-apple-ios aarch64-apple-ios-sim
- Install nightly Rust toolchain (a Lux FHE requirement):
rustup toolchain install nightly
- Install Rust source so as to cross compile
stdlib (a Lux FHE requirement):
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin
2. Compile Lux FHE for use in Swift
- Get Lux FHE:
git clone --branch https://github.com/luxfhe.io/luxfhe.git
- Compile for both iOS and iOS simulator targets:
RUSTFLAGS="" cargo +nightly build -Zbuild-std --release --features=aarch64-unix,high-level-c-api -p tfhe --target aarch64-apple-ios
RUSTFLAGS="" cargo +nightly build -Zbuild-std --release --features=aarch64-unix,high-level-c-api -p tfhe --target aarch64-apple-ios-sim
- Grab generated headers (.h):
cp $(TFHE_RS_PATH)/target/release/tfhe.h $(OUTPUT)/include/tfhe.h
cp $(TFHE_RS_PATH)/target/aarch64-apple-ios/release/deps/tfhe-c-api-dynamic-buffer.h $(OUTPUT)/include/tfhe-c-api-dynamic-buffer.h
- Create a Module Map:
touch $(OUTPUT)/include/module.modulemap
module TFHE {
header "tfhe.h"
header "tfhe-c-api-dynamic-buffer.h"
export *
}
- Grab static librairies (.a): The iOS simulator library needs to be FAT, even if it contains one slice (you can also add an x86-64 slice later on):
lipo -create -output $(OUTPUT)/libtfhe-ios-sim.a $(TFHE_RS_PATH)/target/aarch64-apple-ios-sim/release/libtfhe.a
The iOS device library can be copied this way:
cp $(TFHE_RS_PATH)/target/aarch64-apple-ios/release/libtfhe.a $(OUTPUT)/libtfhe-ios.a
- Package everything into an .xcframework:
xcodebuild -create-xcframework \
-library $(OUTPUT)/libtfhe-ios.a \
-headers $(OUTPUT)/include/ \
-library $(OUTPUT)/libtfhe-ios-sim.a \
-headers $(OUTPUT)/include/ \
-output $(OUTPUT)/TFHE.xcframework
Finally, move the TFHE.xcframework directory into the root directory of the iOS project.
3. Compile Torus ML Extensions for use in Swift
Follow the instructions in the Torus ML Extensions package to build additional Swift bindings that are used by Data Vault.