Wire local TDLib into iOS FFI build

This commit is contained in:
Mikhail Kilin
2026-05-21 15:27:59 +03:00
parent aec3678bd6
commit 217328505c
34 changed files with 24460 additions and 28 deletions

View File

@@ -45,6 +45,33 @@ Architecture default: Rust `tele-core` remains the source of Telegram state and
- Swift sample test can create a fake session, receive events, load chats, open a chat, send a message, react, and search.
- Real TDLib linking is validated for iOS simulator and device or documented as blocked with exact linker error.
#### Phase 2A: Local TDLib for iOS
`tdlib-rs` 1.2.0 with `download-tdlib` downloads prebuilt TDLib archives from `FedericoBruzzone/tdlib-rs` releases using the pattern `tdlib-{tdlib_version}-{target_os}-{target_arch}.zip`. The terminal/macOS build works because the macOS archive exists. The iOS archives, for example `tdlib-1.8.29-ios-aarch64.zip`, are not published, so iOS real linking must not depend on `download-tdlib`.
- Keep `download-tdlib` for the terminal/macOS build path while it remains useful there.
- Switch the iOS FFI build path to `tdlib-rs` `local-tdlib` support.
- Pin the local TDLib build to the TDLib version expected by `tdlib-rs` 1.2.0: `1.8.29`.
- Add `scripts/build-tdlib-ios.sh` to build TDLib locally for:
- `arm64-apple-ios`
- `arm64-apple-ios-sim`
- optionally `x86_64-apple-ios-sim` if Intel Mac simulator support is needed.
- Store generated TDLib artifacts outside git, for example:
- `.build/tdlib-ios/iphoneos/include`
- `.build/tdlib-ios/iphoneos/lib`
- `.build/tdlib-ios/iphonesimulator/include`
- `.build/tdlib-ios/iphonesimulator/lib`
- Add `scripts/build-ios-ffi-with-local-tdlib.sh` to set `LOCAL_TDLIB_PATH` and build `tele-ios-ffi` for simulator/device targets.
- Patch `tdlib-rs` through `crates/vendor/tdlib-rs` until upstream handles `target_os = "ios"` in its `local-tdlib` build helper.
- Run TDLib's host-side `prepare_cross_compiling` target before the iOS cross-build, because TDLib 1.8.29 expects generated TL/MIME sources to exist during cross-compilation.
- After simulator and device Rust builds link, package the Rust FFI output and TDLib dependency into an iOS-consumable XCFramework or documented adjacent native dependency.
- Acceptance:
- `scripts/check-ios-tdlib-linking.sh` no longer fails because of a missing GitHub release archive. Completed on 2026-05-21.
- `cargo build -p tele-ios-ffi --target aarch64-apple-ios-sim --release` links with local TDLib. Completed on 2026-05-21 through `scripts/check-ios-tdlib-linking.sh`.
- `cargo build -p tele-ios-ffi --target aarch64-apple-ios --release` links with local TDLib. Completed on 2026-05-21 through `IOS_RUST_TARGET=aarch64-apple-ios scripts/build-ios-ffi-with-local-tdlib.sh`.
- The Xcode app can be built against the real FFI path, not only the fake bridge. Completed on 2026-05-21 through `scripts/build-ios-real-ffi-xcframework.sh` and `TELE_IOS_USE_LOCAL_FFI=1 scripts/build-ios-simulator-app.sh`.
- Any remaining CMake/OpenSSL/zlib/linker blockers are documented with the exact command and error text.
### Phase 3: iOS App Shell
- Add native app under `apps/ios/TeleTuiIOS`.