Fix iOS WebKit crash by shipping external app.js instead of inlined HTML.

Stop embedding the 1.4MB bundle in index.html to avoid std::overflow_error on launch, validate the iOS asset build, and surface load failures in the native shell.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-06-06 21:53:26 +08:00
parent d9d97552c8
commit db5465c646
5 changed files with 87 additions and 143 deletions
+1 -1
View File
@@ -47,6 +47,6 @@ open ios/WordLoop/WordLoop.xcodeproj
- **界面层**:内嵌 `frontend` 构建产物,经 `wordloop://` 本地协议加载(避免 `file://` 白屏)
- **数据层**:请求发往所选服务器的 `/api`
内嵌页通过 `loadHTMLString` 加载,`app.js` 构建时会内联到 `</body>` 前(避免在 `<head>` 执行时 `#app` 尚未存在导致白屏)
内嵌页通过 `loadFileURL` 加载 Bundle 内 `www/index.html``app.js` / `app.css` 为独立外链文件(**不要**内联进 HTML,否则 WebKit 解析超大 `<script>` 会触发 `std::overflow_error` 崩溃)。构建时脚本放在 `</body>` 前,确保 `#app` 已存在
若出现白屏,请先执行 `bash ios/scripts/build-web-assets.sh`,再在 Xcode **Product → Clean Build Folder** 后重新 Run。