Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
44 changes: 0 additions & 44 deletions ios/tc_helper.xcframework/Info.plist

This file was deleted.

20 changes: 0 additions & 20 deletions ios/tc_helper.xcframework/ios-arm64/tc_helper.framework/Info.plist

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
35 changes: 34 additions & 1 deletion rust/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
17 changes: 17 additions & 0 deletions rust/build_android.sh
Original file line number Diff line number Diff line change
@@ -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/"
76 changes: 76 additions & 0 deletions rust/build_ios.sh
Original file line number Diff line number Diff line change
@@ -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" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>${LIB_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${BUNDLE_ID}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>${MIN_IOS}</string>
</dict>
</plist>
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}"
Loading