diff --git a/.gitignore b/.gitignore index fa364830..587a35de 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,9 @@ app.*.map.json # FVM Version Cache .fvm/ .vscode/settings.json + +# Native libraries compiled from the rust/ crate (tc_helper). +# These are build outputs and must be regenerated locally, not committed. +# See rust/README.md for how to build them. +/android/app/src/main/jniLibs/ +/ios/tc_helper.xcframework/ diff --git a/android/app/src/main/jniLibs/arm64-v8a/libcrc_fast-b3182f249ae653b7.so b/android/app/src/main/jniLibs/arm64-v8a/libcrc_fast-b3182f249ae653b7.so deleted file mode 100755 index 3a8b6827..00000000 Binary files a/android/app/src/main/jniLibs/arm64-v8a/libcrc_fast-b3182f249ae653b7.so and /dev/null differ diff --git a/android/app/src/main/jniLibs/arm64-v8a/libtc_helper.so b/android/app/src/main/jniLibs/arm64-v8a/libtc_helper.so deleted file mode 100755 index 2ed5d305..00000000 Binary files a/android/app/src/main/jniLibs/arm64-v8a/libtc_helper.so and /dev/null differ diff --git a/android/app/src/main/jniLibs/armeabi-v7a/libcrc_fast-c8bd19aec5c73f3a.so b/android/app/src/main/jniLibs/armeabi-v7a/libcrc_fast-c8bd19aec5c73f3a.so deleted file mode 100755 index df205bcd..00000000 Binary files a/android/app/src/main/jniLibs/armeabi-v7a/libcrc_fast-c8bd19aec5c73f3a.so and /dev/null differ diff --git a/android/app/src/main/jniLibs/armeabi-v7a/libtc_helper.so b/android/app/src/main/jniLibs/armeabi-v7a/libtc_helper.so deleted file mode 100755 index 4fa2b74e..00000000 Binary files a/android/app/src/main/jniLibs/armeabi-v7a/libtc_helper.so and /dev/null differ diff --git a/ios/tc_helper.xcframework/Info.plist b/ios/tc_helper.xcframework/Info.plist deleted file mode 100644 index cf3e2802..00000000 --- a/ios/tc_helper.xcframework/Info.plist +++ /dev/null @@ -1,44 +0,0 @@ - - - - - AvailableLibraries - - - BinaryPath - tc_helper.framework/tc_helper - LibraryIdentifier - ios-arm64 - LibraryPath - tc_helper.framework - SupportedArchitectures - - arm64 - - SupportedPlatform - ios - - - BinaryPath - tc_helper.framework/tc_helper - LibraryIdentifier - ios-arm64_x86_64-simulator - LibraryPath - tc_helper.framework - SupportedArchitectures - - arm64 - x86_64 - - SupportedPlatform - ios - SupportedPlatformVariant - simulator - - - CFBundlePackageType - XFWK - XCFrameworkFormatVersion - 1.0 - - diff --git a/ios/tc_helper.xcframework/ios-arm64/tc_helper.framework/Info.plist b/ios/tc_helper.xcframework/ios-arm64/tc_helper.framework/Info.plist deleted file mode 100644 index 4117562b..00000000 --- a/ios/tc_helper.xcframework/ios-arm64/tc_helper.framework/Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleExecutable - tc_helper - CFBundleIdentifier - com.ccextractor.taskwarriorflutter.tc-helper - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - FMWK - CFBundleSignature - ???? - CFBundleVersion - 1.0 - MinimumOSVersion - 13.0 - - diff --git a/ios/tc_helper.xcframework/ios-arm64/tc_helper.framework/tc_helper b/ios/tc_helper.xcframework/ios-arm64/tc_helper.framework/tc_helper deleted file mode 100755 index 458cab50..00000000 Binary files a/ios/tc_helper.xcframework/ios-arm64/tc_helper.framework/tc_helper and /dev/null differ diff --git a/ios/tc_helper.xcframework/ios-arm64_x86_64-simulator/tc_helper.framework/Info.plist b/ios/tc_helper.xcframework/ios-arm64_x86_64-simulator/tc_helper.framework/Info.plist deleted file mode 100644 index 4117562b..00000000 --- a/ios/tc_helper.xcframework/ios-arm64_x86_64-simulator/tc_helper.framework/Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleExecutable - tc_helper - CFBundleIdentifier - com.ccextractor.taskwarriorflutter.tc-helper - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - FMWK - CFBundleSignature - ???? - CFBundleVersion - 1.0 - MinimumOSVersion - 13.0 - - diff --git a/ios/tc_helper.xcframework/ios-arm64_x86_64-simulator/tc_helper.framework/tc_helper b/ios/tc_helper.xcframework/ios-arm64_x86_64-simulator/tc_helper.framework/tc_helper deleted file mode 100755 index cec5b500..00000000 Binary files a/ios/tc_helper.xcframework/ios-arm64_x86_64-simulator/tc_helper.framework/tc_helper and /dev/null differ diff --git a/rust/README.md b/rust/README.md index dc30d093..97f065a7 100644 --- a/rust/README.md +++ b/rust/README.md @@ -1,5 +1,14 @@ ## Rust ⇄ Flutter: Commands +> **Note:** The compiled native libraries are **not** checked into git. They are +> build outputs that must be generated locally before building the app: +> +> - Android: `android/app/src/main/jniLibs/` (`.so` files) +> - iOS: `ios/tc_helper.xcframework/` +> +> Both directories are git-ignored. Use the commands below (or the helper +> scripts `rust/build_android.sh` and `rust/build_ios.sh`) to produce them. + ### Generate Dart bindings ```bash @@ -11,11 +20,35 @@ flutter_rust_bridge_codegen generate \ ### Compile Rust library for Android +Requires [`cargo-ndk`](https://github.com/bbqsrc/cargo-ndk) and the Android NDK. + ```bash cargo ndk -t arm64-v8a -t armeabi-v7a -o ../android/app/src/main/jniLibs build --release ``` -- [ ] these targets are not added yet +Or run the helper script from the `rust/` directory: + +```bash +./build_android.sh +``` + +### Compile Rust library for iOS + +Requires the Apple iOS Rust targets and Xcode command-line tools: + +```bash +rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios +``` + +Build the `tc_helper.xcframework` (device + simulator slices) with the helper +script from the `rust/` directory: + +```bash +./build_ios.sh +``` + +This produces `ios/tc_helper.xcframework`, which the Xcode project embeds as a +framework. ### Run the app diff --git a/rust/build_android.sh b/rust/build_android.sh new file mode 100755 index 00000000..281a6896 --- /dev/null +++ b/rust/build_android.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# Build the tc_helper native libraries for Android and place them in +# android/app/src/main/jniLibs/. +# +# Requires cargo-ndk (https://github.com/bbqsrc/cargo-ndk) and the Android NDK. +# cargo install cargo-ndk +set -euo pipefail + +cd "$(dirname "$0")" + +cargo ndk \ + -t arm64-v8a \ + -t armeabi-v7a \ + -o ../android/app/src/main/jniLibs \ + build --release + +echo "Built native libraries in android/app/src/main/jniLibs/" diff --git a/rust/build_ios.sh b/rust/build_ios.sh new file mode 100755 index 00000000..be64483a --- /dev/null +++ b/rust/build_ios.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# Build tc_helper.xcframework for iOS (device + simulator) and place it at +# ios/tc_helper.xcframework. +# +# Requires the Xcode command-line tools and the iOS Rust targets: +# rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios +set -euo pipefail + +cd "$(dirname "$0")" + +LIB_NAME="tc_helper" +FRAMEWORK="${LIB_NAME}.framework" +MIN_IOS="13.0" +BUNDLE_ID="com.ccextractor.taskwarriorflutter.tc-helper" + +BUILD_DIR="target/ios-framework" +DEVICE_FW="${BUILD_DIR}/device/${FRAMEWORK}" +SIM_FW="${BUILD_DIR}/sim/${FRAMEWORK}" +OUTPUT="../ios/${LIB_NAME}.xcframework" + +# 1. Compile the cdylib for each iOS target. +cargo build --release --target aarch64-apple-ios +cargo build --release --target aarch64-apple-ios-sim +cargo build --release --target x86_64-apple-ios + +# 2. Lay out one .framework per slice; the simulator slice is a fat +# (arm64 + x86_64) binary built with lipo. +rm -rf "${BUILD_DIR}" +mkdir -p "${DEVICE_FW}" "${SIM_FW}" + +cp "target/aarch64-apple-ios/release/lib${LIB_NAME}.dylib" "${DEVICE_FW}/${LIB_NAME}" +lipo -create \ + "target/aarch64-apple-ios-sim/release/lib${LIB_NAME}.dylib" \ + "target/x86_64-apple-ios/release/lib${LIB_NAME}.dylib" \ + -output "${SIM_FW}/${LIB_NAME}" + +# 3. Set the install name to an @rpath relative to the framework, and write the +# framework Info.plist for each slice. +write_plist() { + cat > "$1/Info.plist" < + + + + CFBundleExecutable + ${LIB_NAME} + CFBundleIdentifier + ${BUNDLE_ID} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + ${MIN_IOS} + + +PLIST +} + +for FW in "${DEVICE_FW}" "${SIM_FW}"; do + install_name_tool -id "@rpath/${FRAMEWORK}/${LIB_NAME}" "${FW}/${LIB_NAME}" + write_plist "${FW}" +done + +# 4. Assemble the xcframework. +rm -rf "${OUTPUT}" +xcodebuild -create-xcframework \ + -framework "${DEVICE_FW}" \ + -framework "${SIM_FW}" \ + -output "${OUTPUT}" + +echo "Built ${OUTPUT}"