Zstandard for iOS
v1.5.7iOSZstandard 1.5.7 for React Native apps on iOS, precompiled for arm64 devices and simulators as @crossbind/port-zstd-ios.
Install
The whole flow, including Expo, is in the React Native playbook.
Usage
The examples the WebAssembly page runs, as iOS compiles them: the same headers and the same calls. They are checked on the WebAssembly build.
Compress and decompress a buffer
The two calls most zstd code makes: ZSTD_compress, and ZSTD_decompress with the original size read back from the frame.
Choose a level, a checksum and a window
A context set up with ZSTD_CCtx_setParameter decides what every frame it writes looks like; ZSTD_getFrameHeader reads the choices back.
Compress small messages with a dictionary
Train once with ZDICT_trainFromBuffer, digest it once with ZSTD_createCDict and ZSTD_createDDict, then compress every message against it.
"Stream a file through zstd" writes its input with m.FS, which iOS does not have; the C++ takes paths, so it works unchanged on files in the app's storage. It runs on the WebAssembly page.
What is different on iOS
pod installcompiles your headers with the library through the plugin's podspec, and the app build links the result.- Named imports from
./native/<header>.hwork as on the web:await initNative()once, then call the classes. - There is no
m.FSand no/memfs: files live in the app's own storage, and your C++ takes their paths. - No Worker and no COOP or COEP:
runtime: 'mt'uses pthreads directly.
Other platforms
- Zstandard overview: the apps, every platform's setup and the packages.
- Zstandard for WebAssembly: browsers, Node.js and edge runtimes.
- Zstandard for Android: React Native apps on Android.
- Zstandard for WASI: command-line programs under wasmtime.
Facts on this page come from the port manifests in the repository and from what npm served on beta when the site was built. See the Libraries guide for the full consumer flow.