Skip to content

fix(build): fix add_data_files anchor template and remove broken octagram model references - #1160

Merged
lotem merged 3 commits into
rime:masterfrom
Wujidadi:fix/add-data-files-anchor
Jul 27, 2026
Merged

fix(build): fix add_data_files anchor template and remove broken octagram model references#1160
lotem merged 3 commits into
rime:masterfrom
Wujidadi:fix/add-data-files-anchor

Conversation

@Wujidadi

@Wujidadi Wujidadi commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Problem

When building Squirrel from source, some data files are silently left out of the bundle: deployment reports missing input schema: quick5, and the two octagram grammar files that 4db2c85 intended to bundle (zh-hant-t-essay-bgc.gram, zh-hant-t-essay-bgw.gram) are missing from SharedSupport. Since Xcode does not complain about dangling references, the build still succeeds, which makes the problem easy to miss.

Root cause

The file_ref_entry template in package/add_data_files writes lastKnownFileType = text, while the zhuyin.yaml line used as the sed anchor in the project file actually reads lastKnownFileType = text.yaml. The anchor never matches, so the PBXFileReference insertion silently fails, leaving newly added data files with only the PBXBuildFile, copy phase and group entries. Xcode skips such dangling references without any error, so the files never get copied into Squirrel.app.

The two .gram entries committed in 4db2c85 (build(xcode): bundle octagram data) were generated exactly this way: their PBXFileReference definitions are missing, so apps built from source do not actually contain the two grammar files.

Fix

  • package/add_data_files: derive lastKnownFileType from the file extension (.yamltext.yaml, .txttext, anything else such as .gram → the generic file type with quoted name/path), so the generated anchor matches the real project file and non-YAML assets get a sensible type
  • Squirrel.xcodeproj/project.pbxproj: add the two missing PBXFileReference definitions for the octagram .gram files, reusing the fileRef IDs introduced in 4db2c85

Verification

Full source build on macOS 26.5 (Apple Silicon) with Xcode 26.6: with the fix, quick5.*, grammar.yaml and both .gram files are correctly copied into Squirrel.app/Contents/SharedSupport, and deployment no longer reports missing input schema: quick5. Also verified the script against new dummy .yaml and .gram files under data/plum: each now gets all four project entries, with text.yaml and file types respectively.

Copilot AI review requested due to automatic review settings July 25, 2026 06:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a source-build packaging gap in the Xcode project where some SharedSupport data files could be silently omitted due to a failed PBXFileReference insertion anchor, and restores the missing octagram .gram model references so they’re bundled into the built app.

Changes:

  • Fixes package/add_data_files’s PBXFileReference anchor template so sed insertion matches the real project.pbxproj line for zhuyin.yaml.
  • Adds the missing PBXFileReference entries for two octagram .gram files in Squirrel.xcodeproj/project.pbxproj.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Squirrel.xcodeproj/project.pbxproj Restores missing PBXFileReference definitions for octagram .gram files so Xcode can actually copy them into SharedSupport.
package/add_data_files Updates the generated PBXFileReference template used as the sed anchor for inserting new data files into the Xcode project.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package/add_data_files
Comment on lines 37 to 39
file_ref_entry() {
echo "$2 /* $3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = $3; path = data/plum/$3; sourceTree = \"<group>\"; };"
echo "$2 /* $3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; name = $3; path = data/plum/$3; sourceTree = \"<group>\"; };"
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 2069dba.

Wujidadi added 2 commits July 25, 2026 14:51
…tagram model references

- The file_ref_entry template in package/add_data_files wrote lastKnownFileType = text, while the anchor line for zhuyin.yaml in project.pbxproj actually reads text.yaml, so the sed-based PBXFileReference insertion silently failed
- As a result, newly added data files got only the PBXBuildFile, copy phase and group entries but no PBXFileReference definition; Xcode skips such dangling references without any error, so the files were quietly left out of Squirrel.app
- The two octagram grammar files added in 4db2c85 (build(xcode): bundle octagram data) were affected exactly this way; this commit adds the two missing PBXFileReference definitions, reusing the original fileRef IDs
- Reproducible by building from source: deployment reports "missing input schema: quick5" and the two .gram files are absent from SharedSupport
…files

- Address code review: the previous fix hardcoded text.yaml for all data/plum files, but the script also handles non-YAML assets
- Dispatch by extension: .yaml uses text.yaml, .txt uses text, anything else (e.g. .gram) uses the generic file type with quoted name/path
- The anchor file zhuyin.yaml takes the .yaml branch, so anchor matching is unchanged
@Wujidadi
Wujidadi force-pushed the fix/add-data-files-anchor branch from cbab80d to 2069dba Compare July 25, 2026 06:52
@Wujidadi Wujidadi changed the title fix(build): 修正 add_data_files 錨點模板,補回漏打包的 octagram 語言模型 fix(build): fix add_data_files anchor template and restore missing octagram model references Jul 25, 2026
Wujidadi added a commit to Wujidadi/squirrel that referenced this pull request Jul 25, 2026
- 自 PR rime#1160 分支 cherry-pick(2069dba),回應 Copilot 審查意見的改良版
- file_ref_entry 依副檔名分派:.yaml 用 text.yaml,.txt 用 text,其餘(如 .gram)用 file 型別並將 name/path 加引號
- 程式碼與英文註解刻意保持與上游 PR 逐字一致,待上游合併後同步時可避免內容衝突
Comment thread Squirrel.xcodeproj/project.pbxproj Outdated
447765C725C30E6B002415AF /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = Frameworks/Sparkle.framework; sourceTree = "<group>"; };
448363D925BDBBBF0022C7BA /* pinyin.yaml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; name = pinyin.yaml; path = data/plum/pinyin.yaml; sourceTree = "<group>"; };
448363DA25BDBBBF0022C7BA /* zhuyin.yaml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; name = zhuyin.yaml; path = data/plum/zhuyin.yaml; sourceTree = "<group>"; };
B93B1B771BA746E5EF3B229F /* zh-hant-t-essay-bgw.gram */ = {isa = PBXFileReference; lastKnownFileType = file; name = "zh-hant-t-essay-bgw.gram"; path = "data/plum/zh-hant-t-essay-bgw.gram"; sourceTree = "<group>"; };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否應由 add_data_files 添加?

使用 Makefile 構建沒有這套語言模型。

CI 使用的 action_build.sh 腳本定義的 SQUIRREL_BUNDLED_RECIPES 指定了語言模型的配方包,在 CI 的構建流程中拉取,並添加到工程。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

這麼說來 4db2c85 不完整,應該撤回。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同意,這類動態加入的資料檔,確實不應該寫死。

@lotem

lotem commented Jul 27, 2026

Copy link
Copy Markdown
Member

The script worked. File references to additional downloaded files are correctly added to the project.

diff --git a/Squirrel.xcodeproj/project.pbxproj b/Squirrel.xcodeproj/project.pbxproj
index edde586..fc67439 100644
--- a/Squirrel.xcodeproj/project.pbxproj
+++ b/Squirrel.xcodeproj/project.pbxproj
@@ -36,6 +36,9 @@
 		447765CA25C30E97002415AF /* Sparkle.framework in Copy 3rd-party Frameworks */ = {isa = PBXBuildFile; fileRef = 447765C725C30E6B002415AF /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		448363DD25BDBBED0022C7BA /* pinyin.yaml in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = 448363D925BDBBBF0022C7BA /* pinyin.yaml */; };
 		448363DE25BDBBED0022C7BA /* zhuyin.yaml in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = 448363DA25BDBBBF0022C7BA /* zhuyin.yaml */; };
+		7FC7844F9ED4658A64C54F2C /* zh-hant-t-essay-bgw.gram in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = 9889686D4FD27B58C94DFEE0 /* zh-hant-t-essay-bgw.gram */; };
+		320D90AF0ED8D34DDD47FF7F /* zh-hant-t-essay-bgc.gram in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = 83300E4C09CDCC7B24CCA673 /* zh-hant-t-essay-bgc.gram */; };
+		47E818B3FC2D9EB96B89001F /* grammar.yaml in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = 4AAD579D689585F89DB5CED8 /* grammar.yaml */; };
 		44986A95184B421700B3278D /* LICENSE.txt in Resources */ = {isa = PBXBuildFile; fileRef = 44986A93184B421700B3278D /* LICENSE.txt */; };
 		44986A96184B421700B3278D /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 44986A94184B421700B3278D /* README.md */; };
 		44AEBC7521F569FD00344375 /* key_bindings.yaml in Copy Shared Support Files */ = {isa = PBXBuildFile; fileRef = 44AEBC7221F569CF00344375 /* key_bindings.yaml */; };
@@ -160,6 +163,9 @@
 			files = (
 				448363DD25BDBBED0022C7BA /* pinyin.yaml in Copy Shared Support Files */,
 				448363DE25BDBBED0022C7BA /* zhuyin.yaml in Copy Shared Support Files */,
+				7FC7844F9ED4658A64C54F2C /* zh-hant-t-essay-bgw.gram in Copy Shared Support Files */,
+				320D90AF0ED8D34DDD47FF7F /* zh-hant-t-essay-bgc.gram in Copy Shared Support Files */,
+				47E818B3FC2D9EB96B89001F /* grammar.yaml in Copy Shared Support Files */,
 				441E637722B7E96F006DCCDD /* bopomofo_express.schema.yaml in Copy Shared Support Files */,
 				441E637822B7E96F006DCCDD /* bopomofo_tw.schema.yaml in Copy Shared Support Files */,
 				441E637922B7E96F006DCCDD /* bopomofo.schema.yaml in Copy Shared Support Files */,
@@ -250,6 +256,9 @@
 		447765C725C30E6B002415AF /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = Frameworks/Sparkle.framework; sourceTree = "<group>"; };
 		448363D925BDBBBF0022C7BA /* pinyin.yaml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; name = pinyin.yaml; path = data/plum/pinyin.yaml; sourceTree = "<group>"; };
 		448363DA25BDBBBF0022C7BA /* zhuyin.yaml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; name = zhuyin.yaml; path = data/plum/zhuyin.yaml; sourceTree = "<group>"; };
+		9889686D4FD27B58C94DFEE0 /* zh-hant-t-essay-bgw.gram */ = {isa = PBXFileReference; lastKnownFileType = file; name = "zh-hant-t-essay-bgw.gram"; path = "data/plum/zh-hant-t-essay-bgw.gram"; sourceTree = "<group>"; };
+		83300E4C09CDCC7B24CCA673 /* zh-hant-t-essay-bgc.gram */ = {isa = PBXFileReference; lastKnownFileType = file; name = "zh-hant-t-essay-bgc.gram"; path = "data/plum/zh-hant-t-essay-bgc.gram"; sourceTree = "<group>"; };
+		4AAD579D689585F89DB5CED8 /* grammar.yaml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; name = grammar.yaml; path = data/plum/grammar.yaml; sourceTree = "<group>"; };
 		44986A93184B421700B3278D /* LICENSE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
 		44986A94184B421700B3278D /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.md; sourceTree = "<group>"; };
 		44AEBC7121F569CF00344375 /* punctuation.yaml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = punctuation.yaml; path = data/plum/punctuation.yaml; sourceTree = "<group>"; };
@@ -488,6 +497,9 @@
 			children = (
 				448363D925BDBBBF0022C7BA /* pinyin.yaml */,
 				448363DA25BDBBBF0022C7BA /* zhuyin.yaml */,
+				9889686D4FD27B58C94DFEE0 /* zh-hant-t-essay-bgw.gram */,
+				83300E4C09CDCC7B24CCA673 /* zh-hant-t-essay-bgc.gram */,
+				4AAD579D689585F89DB5CED8 /* grammar.yaml */,
 				441E636C22B7E90D006DCCDD /* bopomofo_express.schema.yaml */,
 				441E636722B7E90D006DCCDD /* bopomofo_tw.schema.yaml */,
 				441E636822B7E90D006DCCDD /* bopomofo.schema.yaml */,
diff --git a/librime b/librime
index 33e7814..d4c324c 160000
--- a/librime
+++ b/librime
@@ -1 +1 @@
-Subproject commit 33e78140250125871856cdc5b42ddc6a5fcd3cd4
+Subproject commit d4c324ca988ed67f45e41524c2ab01d40cb55695

@lotem lotem changed the title fix(build): fix add_data_files anchor template and restore missing octagram model references fix(build): fix add_data_files anchor template and remove broken octagram model references Jul 27, 2026
@lotem
lotem merged commit 325b614 into rime:master Jul 27, 2026
1 check passed
Wujidadi added a commit to Wujidadi/squirrel that referenced this pull request Jul 28, 2026
- 上游 rime#1160(325b614)改為 CI 建置時動態加入,刪除了兩個 .gram 檔與 grammar.yaml 的 PBXBuildFile、copy phase 及 group 共 9 行條目
- merge 後這 9 行與 fork 既有的三行 PBXFileReference 形成懸空參考,恰為當初 bug 的鏡像
- add_data_files 的存在性檢查(grep 檔名)會被懸空參考誤判為已存在而跳過補入,下次建置將靜默漏包 octagram 語言模型,dev-install 的 rsync --delete 更會把已安裝的 gram 檔一併刪除
- 反向套用該 commit 的 pbxproj 刪除段,原樣加回 9 行(沿用原 ID),恢復 fork 的靜態打包形;已驗證 add_data_files 對此冪等(全數 found、不再改動專案檔)
@Wujidadi
Wujidadi deleted the fix/add-data-files-anchor branch July 28, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants