Build input file cannot be found: ‘’. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?

春麗 S.T.E.M.
Aug 28, 2023

--

目錄
1. Target、Scheme 情境下報錯
2. 缺少 plist
3. 檔案名稱錯誤導致的路徑錯誤

⦿ Target、Scheme 情境下報錯
⦿ 缺少 plist
⦿ 檔案名稱錯誤導致的路徑錯誤

Target、Scheme 情境下報錯

在使用不同 Target、Scheme 後,build 時,得到如下的錯誤訊息:

Build input file cannot be found: '/Users/chunlicheng/Desktop/NewProject/FlagAndAnotherScheme/TheSixth copy2-Info.plist'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?

當然這不只在此種使用情境會遇到,這即是告訴你說 plist 檔沒有找到,你首先就要回到專案中找找你的 plist 檔。

如果發現它不在了,我們就打開專案所在的資料夾,如果不容易找到專案所在的資料夾,我們先打開 CLI,拖動專案到你的 CLI,如下:

就會出現如下:

去掉後面 .xcodeproj,就可切換至專案所在資料夾。

若是要打開,則把前方的 cd 改成 open,我們從資料夾找找看有沒有缺失的 plist 檔,如果有就把它放回去專案裡

缺少 plist

如果還是沒有,我們就要想辦法複製出一個 plist,可從原本的 Info 複製,看到如下:

應該就完成了。

檔案名稱錯誤導致的路徑錯誤

若是很不幸的,明明 plist 都在裡面,結果還是報錯,我們就到 Build Settings 裡,All | Combined 裡,搜尋 pack 如下:

在 Packaging 裡,Info.plist File,必須確定右邊檔案名稱,跟你專案裡的 plist 檔案名稱是否一致。

TheSixth/Info.plist 意思是,在 TheSixth 這個 Bundle 下的 Info.plist,這個 TheSixth 不能拿掉;如果我們看到另個 Target,這個名稱更需一致,如下:

完成了!

--

--

春麗 S.T.E.M.
春麗 S.T.E.M.

Written by 春麗 S.T.E.M.

Do not go gentle into that good night, Old age should burn and rave at close of day; Rage, rage, against the dying of the light.

Responses (1)