react-native-swivel
v0.0.1
Published
Swift-first JSI bindings for React Native
Readme
react-native-swivel
react-native-swivel contains the development-time Fast Refresh infrastructure
for Swivel-generated React Native bindings. Public dev APIs and library internals
use refresh naming. Per-generation dynamic libraries use loadable naming.
Metro
Wrap the normal Metro configuration:
const {getDefaultConfig} = require('@react-native/metro-config');
const {withSwivel} = require('react-native-swivel/metro');
module.exports = withSwivel(getDefaultConfig(__dirname), {
projectRoot: __dirname,
outputDir: '.swivel/build',
buildCommand: ['swift', 'swivel', 'build-loadable'],
});The command receives --generation, --changed-file, and --output-dir.
It must print one JSON object:
{
"platform": "ios",
"fileName": "libSwiveled_gen000042.dylib",
"absolutePath": "/project/.swivel/build/libSwiveled_gen000042.dylib",
"schemaHash": "8e21c9fa7b45a1d0",
"abiHash": "1111222233334444"
}For custom build orchestration, pass an async buildLoadable(context) callback
instead. The callback receives an AbortSignal so a stale build can stop work
when a newer Swift edit arrives.
App Client
Install the debug client once during app startup:
import {installSwivelFastRefresh} from 'react-native-swivel';
installSwivelFastRefresh();Register app-owned handle reacquisition callbacks with
NativeHandleRegistry.register(...).
Native
The package includes debug native modules for iOS and Android. They resolve the
Metro host, download a loadable generation artifact into app-private storage,
and pass its unique path to SwivelRefresher, which registers it as the new hot
generation. Prior generations become warm: they stay dlopen'd for the app
session so old HostObjects and Swift metadata stay valid.
The platform-specific loadable-library builder remains app-owned because it
needs the app scheme, simulator architecture, Android ABI, Swift package path,
and signing setup. Every loadable library must export the loadable registration
ABI in native/cpp/SwivelLoadableABI.h.
