💚 End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
update swiftmath integration
Prateek Sunal6fb573de09a7
diff --git a/.gitignore b/.gitignoreindex 4a799e41f1..6714756010 100644--- a/.gitignore+++ b/.gitignore@@ -23,5 +23,17 @@ mobile/native/darwin/Packages/Rust/build/mobile/native/darwin/Apps/ensu/build/target/+# Generated native bindings / binaries (regenerate locally)+mobile/native/android/apps/ensu/crypto-auth-core/src/main/jniLibs/+mobile/native/android/apps/ensu/crypto-auth-core/src/main/java/io/ente/ensu/crypto/ensu_uniffi.kt+mobile/native/android/packages/rust/.gradle/+mobile/native/android/packages/rust/src/main/jniLibs/+mobile/native/android/packages/rust/src/main/kotlin/io/ente/labs/inference_rs/inference_rs_uniffi.kt+mobile/native/android/packages/rust/src/main/kotlin/io/ente/labs/llmchat_db/llmchat_db_uniffi.kt+mobile/native/android/packages/rust/src/main/kotlin/io/ente/labs/llmchat_sync/llmchat_sync_uniffi.kt+mobile/native/darwin/Apps/ensu/ensu/Generated/*_uniffi*+mobile/native/darwin/Packages/Rust/InferenceRSFFI.xcframework/+mobile/native/darwin/Packages/Rust/Sources/InferenceRS/inference_rs_uniffi*+# Local ensu endpoint overrides (compile-time)mobile/native/darwin/Apps/ensu/ensu/Generated/EndpointConfig.swiftdiff --git a/mobile/native/android/apps/ensu/README.md b/mobile/native/android/apps/ensu/README.mdindex e29ee67067..a61ad0e87c 100644--- a/mobile/native/android/apps/ensu/README.md+++ b/mobile/native/android/apps/ensu/README.md@@ -20,6 +20,15 @@ cd mobile/native/android/packages/rust/tool./build_android.sh```+This script produces the JNI `.so` artifacts in `android/packages/rust/src/main/jniLibs/`.+The UniFFI Kotlin bindings are generated separately into:+- `android/apps/ensu/crypto-auth-core/src/main/java/io/ente/ensu/crypto/ensu_uniffi.kt`+- `android/packages/rust/src/main/kotlin/io/ente/labs/*/*_uniffi.kt`++These generated files are gitignored. If bindings are missing, rebuild the corresponding+`rust/*_uniffi` crate(s) and run `uniffi-bindgen generate` for Kotlin (see each crate’s+`uniffi.toml` for package names).+### 2. Build Debug APK```bashdiff --git a/mobile/native/darwin/Apps/ensu/README.md b/mobile/native/darwin/Apps/ensu/README.mdindex 3a3fa80199..46fca1325f 100644--- a/mobile/native/darwin/Apps/ensu/README.md+++ b/mobile/native/darwin/Apps/ensu/README.md@@ -4,6 +4,20 @@All commands below assume you run them from `darwin/Apps/ensu`.+## Generated bindings & dependencies++- SwiftMath is fetched via SwiftPM (`https://github.com/mgriebling/SwiftMath.git`).+- UniFFI Swift bindings are generated locally and gitignored:+ - `ensu/Generated/*_uniffi*`+ - `../Packages/Rust/Sources/InferenceRS/inference_rs_uniffi*`+ - `../Packages/Rust/InferenceRSFFI.xcframework`++The Xcode build script (`scripts/build-rust.sh`) builds Rust static libs, but it does+not regenerate the Swift bindings. If bindings are missing, build the corresponding+`rust/*_uniffi` crate and run `uniffi-bindgen generate` to output into the paths above.+`../Packages/Rust/tool/generate_bindings.sh` and `../Packages/Rust/tool/build_xcframework.sh`+handle the InferenceRS bindings and xcframework.+### Debug Build (Simulator)```bashcd darwin/Apps/ensudiff --git a/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj b/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxprojindex 8cfc37625e..07658e5fb3 100644--- a/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj+++ b/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.pbxproj@@ -13,8 +13,8 @@DAB0F20E2F5E123400ABCD01 /* InferenceRS in Frameworks (macOS) */ = {isa = PBXBuildFile; productRef = DAB0F20C2F5E123400ABCD01 /* InferenceRS */; };DAF584672E61BB8300F8A08F /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = DAF584662E61BB8300F8A08F /* ZIPFoundation */; };DAF584682E61BB8300F8A08F /* ZIPFoundation in Frameworks (macOS) */ = {isa = PBXBuildFile; productRef = DAF584662E61BB8300F8A08F /* ZIPFoundation */; };- DBA3E91C2F7A6B9000AA11BB /* iosMath in Frameworks */ = {isa = PBXBuildFile; productRef = DBA3E91B2F7A6B9000AA11BB /* iosMath */; };- DBA3E91D2F7A6B9000AA11BB /* iosMath in Frameworks (macOS) */ = {isa = PBXBuildFile; productRef = DBA3E91B2F7A6B9000AA11BB /* iosMath */; };+ DBA3E91C2F7A6B9000AA11BB /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = DBA3E91B2F7A6B9000AA11BB /* SwiftMath */; };+ DBA3E91D2F7A6B9000AA11BB /* SwiftMath in Frameworks (macOS) */ = {isa = PBXBuildFile; productRef = DBA3E91B2F7A6B9000AA11BB /* SwiftMath */; };DB9F1C3C2F9D123400ABCD02 /* Markdown in Frameworks */ = {isa = PBXBuildFile; productRef = DB9F1C3B2F9D123400ABCD02 /* Markdown */; };DB9F1C3D2F9D123400ABCD02 /* Markdown in Frameworks (macOS) */ = {isa = PBXBuildFile; productRef = DB9F1C3B2F9D123400ABCD02 /* Markdown */; };/* End PBXBuildFile section */@@ -67,7 +67,7 @@DACC3DC92E618D6A00DAF993 /* EnteNetwork in Frameworks */,DAB0F20D2F5E123400ABCD01 /* InferenceRS in Frameworks */,DAF584672E61BB8300F8A08F /* ZIPFoundation in Frameworks */,- DBA3E91C2F7A6B9000AA11BB /* iosMath in Frameworks */,+ DBA3E91C2F7A6B9000AA11BB /* SwiftMath in Frameworks */,DB9F1C3C2F9D123400ABCD02 /* Markdown in Frameworks */,);runOnlyForDeploymentPostprocessing = 0;@@ -79,7 +79,7 @@21BBA57867859DAD206D6A46 /* EnteNetwork in Frameworks (macOS) */,DAB0F20E2F5E123400ABCD01 /* InferenceRS in Frameworks (macOS) */,DAF584682E61BB8300F8A08F /* ZIPFoundation in Frameworks (macOS) */,- DBA3E91D2F7A6B9000AA11BB /* iosMath in Frameworks (macOS) */,+ DBA3E91D2F7A6B9000AA11BB /* SwiftMath in Frameworks (macOS) */,DB9F1C3D2F9D123400ABCD02 /* Markdown in Frameworks (macOS) */,);runOnlyForDeploymentPostprocessing = 0;@@ -150,7 +150,7 @@DACC3DC82E618D6A00DAF993 /* EnteNetwork */,DAB0F20C2F5E123400ABCD01 /* InferenceRS */,DAF584662E61BB8300F8A08F /* ZIPFoundation */,- DBA3E91B2F7A6B9000AA11BB /* iosMath */,+ DBA3E91B2F7A6B9000AA11BB /* SwiftMath */,DB9F1C3B2F9D123400ABCD02 /* Markdown */,);productName = ensu;@@ -178,7 +178,7 @@DACC3DC82E618D6A00DAF993 /* EnteNetwork */,DAB0F20C2F5E123400ABCD01 /* InferenceRS */,DAF584662E61BB8300F8A08F /* ZIPFoundation */,- DBA3E91B2F7A6B9000AA11BB /* iosMath */,+ DBA3E91B2F7A6B9000AA11BB /* SwiftMath */,DB9F1C3B2F9D123400ABCD02 /* Markdown */,);productName = Ensu;@@ -263,7 +263,7 @@packageReferences = (DACC3DC62E618D5300DAF993 /* XCLocalSwiftPackageReference "../../Packages/EnteNetwork" */,DAB0F20B2F5E123400ABCD01 /* XCLocalSwiftPackageReference "../../Packages/Rust" */,- DBA3E91A2F7A6B9000AA11BB /* XCLocalSwiftPackageReference "../../Packages/iosMath" */,+ DBA3E91A2F7A6B9000AA11BB /* XCRemoteSwiftPackageReference "SwiftMath" */,DAF584652E61BB6300F8A08F /* XCRemoteSwiftPackageReference "ZIPFoundation" */,DB9F1C3A2F9D123400ABCD02 /* XCRemoteSwiftPackageReference "swift-markdown" */,);@@ -875,10 +875,6 @@isa = XCLocalSwiftPackageReference;relativePath = ../../Packages/Rust;};- DBA3E91A2F7A6B9000AA11BB /* XCLocalSwiftPackageReference "../../Packages/iosMath" */ = {- isa = XCLocalSwiftPackageReference;- relativePath = ../../Packages/iosMath;- };/* End XCLocalSwiftPackageReference section *//* Begin XCRemoteSwiftPackageReference section */@@ -898,6 +894,14 @@minimumVersion = 0.3.0;};};+ DBA3E91A2F7A6B9000AA11BB /* XCRemoteSwiftPackageReference "SwiftMath" */ = {+ isa = XCRemoteSwiftPackageReference;+ repositoryURL = "https://github.com/mgriebling/SwiftMath.git";+ requirement = {+ kind = upToNextMajorVersion;+ minimumVersion = 1.7.3;+ };+ };/* End XCRemoteSwiftPackageReference section *//* Begin XCSwiftPackageProductDependency section */@@ -909,10 +913,10 @@isa = XCSwiftPackageProductDependency;productName = InferenceRS;};- DBA3E91B2F7A6B9000AA11BB /* iosMath */ = {+ DBA3E91B2F7A6B9000AA11BB /* SwiftMath */ = {isa = XCSwiftPackageProductDependency;- package = DBA3E91A2F7A6B9000AA11BB /* XCLocalSwiftPackageReference "../../Packages/iosMath" */;- productName = iosMath;+ package = DBA3E91A2F7A6B9000AA11BB /* XCRemoteSwiftPackageReference "SwiftMath" */;+ productName = SwiftMath;};DAF584662E61BB8300F8A08F /* ZIPFoundation */ = {isa = XCSwiftPackageProductDependency;diff --git a/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolvedindex 9c1fadb0a5..d9313608e5 100644--- a/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved+++ b/mobile/native/darwin/Apps/ensu/ensu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved@@ -28,6 +28,15 @@"version" : "0.7.3"}},+ {+ "identity" : "swiftmath",+ "kind" : "remoteSourceControl",+ "location" : "https://github.com/mgriebling/SwiftMath.git",+ "state" : {+ "revision" : "fa8244ed032f4a1ade4cb0571bf87d2f1a9fd2d7",+ "version" : "1.7.3"+ }+ },{"identity" : "swift-tagged","kind" : "remoteSourceControl",diff --git a/mobile/native/darwin/Apps/ensu/ensu/Chat/LaTeXView.swift b/mobile/native/darwin/Apps/ensu/ensu/Chat/LaTeXView.swiftindex 31095097c0..1a607d5515 100644--- a/mobile/native/darwin/Apps/ensu/ensu/Chat/LaTeXView.swift+++ b/mobile/native/darwin/Apps/ensu/ensu/Chat/LaTeXView.swift@@ -1,6 +1,6 @@#if canImport(EnteCore)import SwiftUI-import iosMath+import SwiftMathstruct LaTeXView: View {let latex: Stringdiff --git a/mobile/native/darwin/Packages/Rust/README.md b/mobile/native/darwin/Packages/Rust/README.mdindex 629fdddffc..9262024546 100644--- a/mobile/native/darwin/Packages/Rust/README.md+++ b/mobile/native/darwin/Packages/Rust/README.md@@ -7,12 +7,13 @@ Swift bindings generated via UniFFI for the Rust core in `../rust`.From the repo root:```bash-cd swift+cd mobile/native/darwin/Packages/Rust./tool/generate_bindings.sh```This writes the Swift sources plus the UniFFI header/modulemap into-`swift/Sources/InferenceRS`.+`Sources/InferenceRS`. These generated files are gitignored—re-run the script+whenever you need to regenerate bindings.Note: The script applies the llama.cpp mtmd patch (requires `python3`). Set`APPLY_LLAMA_MTMD_PATCH=0` to skip it.@@ -22,12 +23,13 @@ Note: The script applies the llama.cpp mtmd patch (requires `python3`). SetFrom the repo root:```bash-cd swift+cd mobile/native/darwin/Packages/Rust./tool/build_xcframework.sh```-This produces `swift/InferenceRSFFI.xcframework`, which the Swift package-references as a binary target.+This produces `InferenceRSFFI.xcframework`, which the Swift package references+as a binary target. The xcframework is gitignored and should be generated+locally as needed.Note: The build applies the llama.cpp mtmd patch (requires `python3`). Set`APPLY_LLAMA_MTMD_PATCH=0` to skip it.