UNPKG

zk-expo

Version:

Expo Module to create Zero-Knowledge Proofs for Groth16 & Noir on iOS and Android.

50 lines (43 loc) 1.84 kB
const { withDangerousMod } = require('@expo/config-plugins'); const path = require('path'); const fs = require('fs'); /** * Strips DWARF debug sections from libnative_rust_lib.a inside the ZkExpo * xcframework. Required for Xcode 26+ where dsymutil crashes when the linked * binary includes DWARF from ring-crate assembly stubs that have no * corresponding debug map entries. * * `strip -S` removes only DWARF; the symbol table is preserved so linking and * Sentry symbolication for all other code are unaffected. * * @see https://github.com/anudit/zk-expo/issues */ function withZkExpoRustFix(config) { return withDangerousMod(config, [ 'ios', (c) => { const podfilePath = path.join(c.modRequest.platformProjectRoot, 'Podfile'); let contents = fs.readFileSync(podfilePath, 'utf8'); if (contents.includes('# [withZkExpoRustFix]')) return c; const patch = ` # [withZkExpoRustFix] Strip DWARF from libnative_rust_lib.a (zk-expo / ring crate) # dsymutil on Xcode 26+ panics on ring's assembly symbols which have no debug map entry. # strip -S removes DWARF only; symbol table is preserved so linking is unaffected. zk_xcframework = File.join(installer.sandbox.pod_dir('ZkExpo'), 'libnative_rust_lib.xcframework') zk_stripped_marker = File.join(zk_xcframework, '.dwarf_stripped') if File.exist?(zk_xcframework) && !File.exist?(zk_stripped_marker) Dir.glob(File.join(zk_xcframework, '**', '*.a')).each do |lib| system("xcrun strip -S '#{lib}' 2>/dev/null") end File.write(zk_stripped_marker, '') end`; contents = contents.replace( /(react_native_post_install\([\s\S]*?\)\s*\n)/, `$1${patch}\n`, ); fs.writeFileSync(podfilePath, contents); return c; }, ]); } module.exports = withZkExpoRustFix;