/** * expo-sqlite copies vendor/sqlite3/*.c into ios/ during `pod install` (see ExpoSQLite.podspec). * After a fresh `npm install`, Xcode can fail with missing sqlite3.c until pods run. * This script mirrors that copy so native builds work without an extra manual step. */ const fs = require('fs'); const path = require('path'); const appRoot = path.join(__dirname, '..'); const pkgRoot = path.join(appRoot, 'node_modules', 'expo-sqlite'); function readUseLibSQL() { const propsPath = path.join(appRoot, 'ios', 'Podfile.properties.json'); if (!fs.existsSync(propsPath)) { return false; } try { const props = JSON.parse(fs.readFileSync(propsPath, 'utf8')); return props['expo.sqlite.useLibSQL'] === 'true'; } catch { return false; } } function main() { if (!fs.existsSync(pkgRoot)) { return; } if (readUseLibSQL()) { return; } const vendorDir = path.join(pkgRoot, 'vendor', 'sqlite3'); const iosDir = path.join(pkgRoot, 'ios'); for (const file of ['sqlite3.c', 'sqlite3.h']) { const src = path.join(vendorDir, file); const dest = path.join(iosDir, file); if (!fs.existsSync(src)) { console.warn(`[ensure-expo-sqlite-ios] missing vendor file: ${src}`); continue; } if (fs.existsSync(dest)) { continue; } fs.mkdirSync(iosDir, { recursive: true }); fs.copyFileSync(src, dest); console.log(`[ensure-expo-sqlite-ios] copied ${file} -> ios/`); } } main();