Skip to content

debanjanbasu/platypus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Platypus Logo

What am I?

Ah, the joys of modern native development! You've got iOS whispering Swift, Android chatting in Kotlin, Windows holding forth in C++, and Linux keeping it real with C. As a developer trying to serve them all, it can feel like you're constantly context-switching just to say "hello world" natively. We felt that pain too. So, we decided to embrace the madness (so you don't have to!) by creating Platypus: a pure-Rust library designed to provide a standard, cross-platform way to interact with native device features. Think of Platypus, the animal – a fascinating creature, a bit of a mashup, right? That's us! We're bringing together the seemingly disparate worlds of native APIs under one efficient, Rusty roof. Our goal is to deliver the fastest possible performance with the simplest API for accessing native elements, bridging the gaps between these platform islands.

Prerequisites

First things first: you'll need the usual native development toolchains installed, such as Xcode, Visual Studio Tools, and the like. Detailing the installation steps for all of those would be a documentation project in itself, so we'll assume you've conquered those beasts before. Consider this project a slightly more advanced challenge; it helps to have a good grasp of Swift, Rust, the unique joys of Windows development, WASM, web-sys, and potentially a strong cup of coffee nearby.

Hope one day, we get true Rust compatibility with these vendors, till then, we do with whatever we've got in our arsenal.

Status Updates

Behold! A mystical table detailing the current state of our various components (or 'crates', if you're fancy) and the ongoing battle to make them play nicely with every operating system imaginable:

Crate macOS iOS watchOS macCatalyst visionOS Android Windows Linux WASM
biometrics
Version v10.15+ v13+ v7+ v13+ v1+

Contributing

Create a generic swift-library when needed inside your package

This is to create a generic swift-library when needed, and remove the git svn that's generated by the swift package init command.

mkdir -p swift-library && cd swift-library
swift package init --name swift-library --type library --disable-xctest --disable-swift-testing
rm -rf .git*

build.rs

Our build.rs script is a marvel of automation... mostly. But when it comes to bridging-header.h, the sacred text that lets Swift and Rust actually talk to each other without awkward silences, you'll need to play human courier. Simply copy-paste it to the root of swift-library. Think of it as the final boss battle.

Running

The simplest way is just do:

cargo test

To check if it's building:

cargo build

Usage

For now you can directly link to the libraries:

[dependencies]
biometric = { git = "https://github.com/debanjanbasu/platypus.git", branch = "main" }

Parent apps don't respect environment variables setup by rustc, so you'll need to add this to your build.rs ideally for apple platforms:

println!("cargo:rustc-link-search=native=/usr/lib/swift");

About

Am I a duck, am I a beaver, am I a rat? I'm a platypus!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published