// Build a standalone simulator .app. Run outside `nix develop`. import { spawnSync, execFileSync } from 'node:child_process'; import { existsSync, rmSync } from 'node:fs'; const env = { ...process.env, DEVELOPER_DIR: '/Applications/Xcode.app/Contents/Developer' }; for (const k of [ 'SDKROOT', 'MACOSX_DEPLOYMENT_TARGET', 'NIX_CFLAGS_COMPILE', 'NIX_CFLAGS_COMPILE_FOR_BUILD', ]) delete env[k]; rmSync('src-tauri/gen/apple/build', { recursive: true, force: true }); // tauri ios build compiles a valid sim .app but then errors trying to move it // into an .xcarchive; ignore that exit and take the .app it produced. spawnSync('pnpm', ['tauri', 'ios', 'build', '--target', 'aarch64-sim'], { stdio: 'inherit', env }); const app = execFileSync( 'bash', [ '-lc', `ls -td ${process.env.HOME}/Library/Developer/Xcode/DerivedData/synapse-*/Build/Products/*-iphonesimulator/Synapse.app 2>/dev/null | head -1`, ], { encoding: 'utf8' }, ).trim(); if (!app || !existsSync(app)) { console.error('No simulator Synapse.app was produced.'); process.exit(1); } console.log(`\nSimulator app: ${app}`); console.log('Install + launch on a booted simulator:'); console.log(` xcrun simctl install booted "${app}"`); console.log(' xcrun simctl launch booted com.denishovart.synapseapp');