在越狱的iPhone上从源代码编译了Node.js 18,以运行Claude Code。
在越狱的 iPhone 12 Pro Max(iOS 16.5,Dopamine)上原生构建了 Node.js 18.20.4,以运行 Claude Code - 无需 SSH 连接到服务器。
关键发现:
- 苹果的 -fembed-bitcode 标志使每个 .o 文件增加了 11MB 的开销,而实际代码只有 58KB,导致 V8 库膨胀至 6.8GB + 4.5GB。
- 从 common.gypi 中移除该标志后,构建体积从 29GB 降至 8GB 以下。
- 由于 iOS 没有 Xcode,需要使用伪造的 xcrun/xcodebuild 脚本。
- 每个构建工具(mksnapshot、torque 等)在构建过程中都需要 ldid 签名。
- 最终的二进制文件需要 --no-wasm-code-gc 标志,以应对 iOS 的内存管理问题。
最终结果:71MB 的 Node 二进制文件,支持完整的 WebAssembly 和 ICU,Claude Code 以交互方式运行。
视频链接:[https://www.youtube.com/shorts/NXgqi1jgSq0](https://www.youtube.com/shorts/NXgqi1jgSq0)
查看原文
Built Node.js 18.20.4 natively on a jailbroken iPhone 12 Pro Max (iOS 16.5, Dopamine) to run Claude Code - no SSH to a server.<p>Key discoveries:
- Apple's -fembed-bitcode flag added 11MB overhead per .o file vs 58KB actual code, bloating V8 libraries to 6.8GB+4.5GB
- Removing the flag from common.gypi dropped the build from 29GB to under 8GB
- Required fake xcrun/xcodebuild scripts since iOS has no Xcode
- Every build tool (mksnapshot, torque, etc.) needs ldid signing mid-build
- Final binary needed --no-wasm-code-gc flag due to iOS memory management quirks<p>Final result: 71MB node binary with full WebAssembly + ICU support, Claude Code running interactively.<p>Video: https://www.youtube.com/shorts/NXgqi1jgSq0