fix(build): fix add_data_files anchor template and remove broken octagram model references - #1160
Conversation
There was a problem hiding this comment.
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’sPBXFileReferenceanchor template so sed insertion matches the realproject.pbxprojline forzhuyin.yaml. - Adds the missing
PBXFileReferenceentries for two octagram.gramfiles inSquirrel.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.
| 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>\"; };" | ||
| } |
…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
cbab80d to
2069dba
Compare
- 自 PR rime#1160 分支 cherry-pick(2069dba),回應 Copilot 審查意見的改良版 - file_ref_entry 依副檔名分派:.yaml 用 text.yaml,.txt 用 text,其餘(如 .gram)用 file 型別並將 name/path 加引號 - 程式碼與英文註解刻意保持與上游 PR 逐字一致,待上游合併後同步時可避免內容衝突
| 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>"; }; |
There was a problem hiding this comment.
是否應由 add_data_files 添加?
使用 Makefile 構建沒有這套語言模型。
CI 使用的 action_build.sh 腳本定義的 SQUIRREL_BUNDLED_RECIPES 指定了語言模型的配方包,在 CI 的構建流程中拉取,並添加到工程。
There was a problem hiding this comment.
同意,這類動態加入的資料檔,確實不應該寫死。
|
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 |
- 上游 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、不再改動專案檔)
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 fromSharedSupport. Since Xcode does not complain about dangling references, the build still succeeds, which makes the problem easy to miss.Root cause
The
file_ref_entrytemplate inpackage/add_data_fileswriteslastKnownFileType = text, while thezhuyin.yamlline used as the sed anchor in the project file actually readslastKnownFileType = text.yaml. The anchor never matches, so thePBXFileReferenceinsertion silently fails, leaving newly added data files with only thePBXBuildFile, copy phase and group entries. Xcode skips such dangling references without any error, so the files never get copied intoSquirrel.app.The two
.gramentries committed in 4db2c85 (build(xcode): bundle octagram data) were generated exactly this way: theirPBXFileReferencedefinitions are missing, so apps built from source do not actually contain the two grammar files.Fix
package/add_data_files: derivelastKnownFileTypefrom the file extension (.yaml→text.yaml,.txt→text, anything else such as.gram→ the genericfiletype with quoted name/path), so the generated anchor matches the real project file and non-YAML assets get a sensible typeSquirrel.xcodeproj/project.pbxproj: add the two missingPBXFileReferencedefinitions for the octagram.gramfiles, reusing the fileRef IDs introduced in 4db2c85Verification
Full source build on macOS 26.5 (Apple Silicon) with Xcode 26.6: with the fix,
quick5.*,grammar.yamland both.gramfiles are correctly copied intoSquirrel.app/Contents/SharedSupport, and deployment no longer reportsmissing input schema: quick5. Also verified the script against new dummy.yamland.gramfiles underdata/plum: each now gets all four project entries, withtext.yamlandfiletypes respectively.