Skip to content

安裝版 app 自包含修復未生效:Bundle.module 仍吃 repo .build fallback,刪 .build 即崩(#99 殘留) #107

Description

@kiki830621

Problem

#99 的自包含修復(fee1e57 — Makefile 把 *.bundle 複製進 Contents/Resources/未實際生效:安裝版 /Applications/Logos.appBundle.module(SwiftTerm fork 的 MetalTerminalRenderer.candidateBundles() 路徑)在 runtime 仍解析到 repo .build 的 dev-fallback,從未使用 Resources 內嵌的那份。結果是:

  • repo .build/arm64-apple-macosx/release/ 存在 → app 正常。
  • .build 被刪(例如 clean-gate rm -rf .build && swift test)→ 安裝版 app 啟動即崩SIGTRAPlibswiftCore assertionFailure in NSBundle.module one-time init → MetalTerminalRenderer.candidateBundles())。

Type

bug

實害(2026-08-01)

當日為另一 issue 跑 clean gate 刪了 .build使用者執行中的 Logos(他的工作 terminal)隨之崩潰,且之後點開 app 都是啟動即崩(crash reports Logos-2026-08-01-164122/164221.ips),直到重建 release 產物才復活。「開發 repo 的清理動作可以殺掉已安裝的 app」——這正是 #99 想消滅的耦合,實測仍在。

Evidence

  1. 安裝版(Jul 27,晚於 fee1e57 Jul 19)的 Contents/Resources/SwiftTerm_SwiftTerm.bundle 存在且含 Shaders.metal —— 內嵌步驟有跑。
  2. strings 安裝版 binary:內嵌 fallback 絕對路徑為 <repo>/.build/arm64-apple-macosx/release/SwiftTerm_SwiftTerm.bundle(與 Highlightr_Highlightr.bundle 同)。
  3. 決定性實驗(做過兩次,一次在 Installed Logos.app crashes at launch: SwiftPM resource bundles never embedded, Bundle.module dev-path fallback broken by .build clean #99、一次在今日):不動安裝版、只重建 swift build -c release → app 復活。⇒ runtime 實際使用的是 .build 那份,Resources 那份從未被選中。

未定的根因細節(留給 diagnose)

SwiftPM 生成的 Bundle.module accessor 候選順序理論上是 Bundle.main.resourceURL 優先、build-dir fallback 在後。Resources копия存在卻仍走 fallback,可能性包括:Bundle(url:) 對「無 Info.plist 的裸 .bundle 目錄」回 nil(內嵌那份只有 Shaders.metal 一個檔案,無 bundle 結構)、或 accessor 候選順序與假設不符。需要對照 fork 內 accessor 生成物確認。

Expected

安裝版 app 完全自包含:.build 整個刪除後,/Applications/Logos.app 照常啟動、terminal/Metal 照常運作。驗收方式(#99 時記載過但顯然未以此驗過):mv .build .build.away && open -a Logos → 存活;mv 回來。

Workaround(現行)

.build 後跑一次 swift build -c release 餵 fallback;或避免在安裝版可能被使用時清 .build

Notes

Current Status

Phase: verified

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions