Skip to content

feat(bindings): Added UniFFI bindings to generate swift & kotlin code - #255

Open
ActuallyTaylor wants to merge 3 commits into
firecrawl:mainfrom
impel-intelligence:feat/uniffi-bindings
Open

feat(bindings): Added UniFFI bindings to generate swift & kotlin code#255
ActuallyTaylor wants to merge 3 commits into
firecrawl:mainfrom
impel-intelligence:feat/uniffi-bindings

Conversation

@ActuallyTaylor

@ActuallyTaylor ActuallyTaylor commented Aug 4, 2026

Copy link
Copy Markdown

Adds (UniFFI)[https://github.com/mozilla/uniffi-rs] bindings for generating Swift & Kotlin bindings. This is particularly useful for using the library in an iOS or macOS app.

UniFFI builds are gated behind the uniffi feature. Swift bindings can be generated using these commands:

cargo build --release --features uniffi
cargo run --release --features uniffi --bin uniffi-bindgen -- generate \
                --library "target/release/libpdf_inspector.dylib" \
                --language swift \
                --out-dir swift

Notes

This PR was written with Swift compatibility in mind. Because of this, there are no release workflows like other bindings. Swift Package Manager does not have a central repository, and rather relies directly on GitHub repositories. Properly packaging a UniFFI dependency into a Swift package requires building an artifact bundle with the rust sources pre-compiled.

There is a work in progress approach for updating the swift package with release cuts, however it is currently blocked because there is no clear way to update the Package.swift file with new artifact information before a tag is created.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Add uniffi bindings to generate Swift and Kotlin APIs for pdf_inspector, enabling iOS, macOS, and Android integration. Bindings are behind the uniffi feature, with a new uniffi-bindgen helper binary and staticlib crate type for Apple linking.

  • New Features

    • Added uniffi feature, build integration, scaffolding, and ffi module.
    • Exported APIs: process_pdf(_/bytes), detect_pdf(_/bytes), classify_pdf(_/bytes), extract_text(_/bytes), with unified error mapping.
    • New uniffi-bindgen binary for generating Swift/Kotlin bindings.
    • Richer result types: layout complexity, OCR reasons by page, metadata, confidence, and encoding issues.
    • Added staticlib crate type for Swift consumption.
  • Migration

    • Build with: cargo build --release --features uniffi
    • Generate bindings: cargo run --release --features uniffi --bin uniffi-bindgen -- generate --library target/release/libpdf_inspector.dylib --language swift --out-dir swift (use --language kotlin for Kotlin)
    • Swift packaging is not automated; SPM needs an artifact bundle and Package.swift updates outside this PR.

Written for commit 74301cc. Summary will update on new commits.

Review in cubic

@ActuallyTaylor

Copy link
Copy Markdown
Author

A question for the maintainers, what is the release process of this repository? Would it make sense for their to be a local script that updates the Package.swift file and creates a release that contains just the compiled rust code. This would be the cleanest approach to support SPM but adds more steps to the release process of the repo.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Shadow auto-approve: would not auto-approve because issues were found.

Fix all with cubic | Re-trigger cubic

Comment thread src/ffi.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant