Add SwiftUI native read bindings#845
Open
ubermensch1218 wants to merge 3 commits into
Open
Conversation
added 3 commits
May 12, 2026 14:44
The native binding crate already provides a stable C ABI for text and Markdown export, so the Swift port starts as a thin SwiftPM package over that ABI instead of duplicating parser logic. The wrapper keeps file-based export semantics intact while giving Swift callers typed results and errors. Constraint: Existing portable surface is the bindings/Native C ABI Rejected: Rewrite the parser in Swift | would duplicate the Rust document model before the ABI is proven in apps Confidence: high Scope-risk: narrow Directive: Keep Swift API additions aligned with bindings/Native symbols until an XCFramework packaging step is introduced Tested: cargo build --manifest-path bindings/Native/Cargo.toml Tested: swift test -Xlinker -L../../bindings/Native/target/debug Not-tested: iOS app bundle/XCFramework runtime packaging
Swift app integration needs an Apple-native binary artifact, so the native FFI crate now emits a static library and the release helper assembles device, simulator, and macOS slices into RhwpNative.xcframework with a zipped archive and checksum. Constraint: Xcode consumes native Rust code most cleanly through XCFramework artifacts Rejected: Commit generated XCFramework output | binary release artifacts should stay under ignored dist/swift Confidence: high Scope-risk: narrow Directive: Keep the generated archive out of git; rerun scripts/package-swift-xcframework.sh for release assets Tested: ./scripts/package-swift-xcframework.sh Tested: swift test -Xlinker -L../../bindings/Native/target/debug Not-tested: importing the generated XCFramework into a real iOS app target
Swift app callers need document content in memory, not a TXT export side effect. The native ABI now exposes rhwp_read_text, Swift decodes that into page models, and the package includes a SwiftUI text view that loads an HWP URL and displays extracted pages. Constraint: SwiftUI display should not depend on temporary export files Rejected: Reuse rhwp_export_text for UI display | it writes TXT files and returns paths instead of document content Confidence: high Scope-risk: moderate Directive: Keep read APIs side-effect free; export APIs remain the file-writing surface Tested: cargo test --manifest-path bindings/Native/Cargo.toml Tested: cargo build --manifest-path bindings/Native/Cargo.toml Tested: swift test -Xlinker -L../../bindings/Native/target/debug Tested: ./scripts/package-swift-xcframework.sh Tested: unpacked XCFramework ZIP macOS slice linked to rhwp_read_text against samples/KTX.hwp Not-tested: rendering inside a live iOS simulator app target
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rhwp_read_textand exposeRhwpDocumentTextViewfor SwiftUI displayVerification
cargo test --manifest-path bindings/Native/Cargo.tomlcargo build --manifest-path bindings/Native/Cargo.tomlswift test -Xlinker -L../../bindings/Native/target/debug./scripts/package-swift-xcframework.shrhwp_read_textagainstsamples/KTX.hwpRhwpDocumentTextViewand confirmed HWP text rendered on screenNotes