一饶碘、錯(cuò)誤日志
Invalid Mach-O header. The __swift5_entry section is missing for the “Payload/xx.app/PlugIns/xxxExtension.appex” extension bundle, which prevents the extension from running. You can run the otool command against your binary to ensure there’s a __swift5_entry section. (ID: xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx)
二平痰、問題源頭
因?yàn)轫?xiàng)目一次性開發(fā)了10個(gè)小組件需要更新版本,10個(gè)小組件創(chuàng)建的時(shí)候都是用的File -> New -> Target,但是只留了一個(gè) WidgetBundle 作為 main 主入口,10個(gè)組件都放到同一個(gè) WidgetBundle 里面引用
以上,本地開發(fā)調(diào)試枷邪,以及打包安裝調(diào)試都OK,但提審 上傳ipa的時(shí)候诺凡,報(bào)錯(cuò)了东揣。
Invalid Mach-O header. The __swift5_entry section is missing for the “Payload/xx.app/PlugIns/xxxExtension.appex” extension bundle药薯。
三、解決方法
只保留一個(gè)target救斑,然后將10個(gè)小組件的Widget Struct 文件復(fù)制到此target下童本。修改后的目錄結(jié)構(gòu):
第一次做小組件開發(fā),不確定實(shí)現(xiàn)多個(gè)小組件是這種方法好脸候,還是有其他的方法穷娱。歷經(jīng)半個(gè)月從沒有接觸過swiftUI到開發(fā)完10個(gè)小組件,中間也經(jīng)歷過幾個(gè)坑(定時(shí)刷新运沦,多個(gè)組件的實(shí)現(xiàn)泵额,組件按鈕的點(diǎn)擊傳參,ipa上傳的“Invalid Mach-O header.”錯(cuò)誤等等)携添。但是嫁盲,辦法總比困難多。
因?yàn)樽约涸诰W(wǎng)上也沒有找到這個(gè)問題的解決方法烈掠,特意把錯(cuò)誤的日志信息貼文章里面羞秤,方便檢索。如果有類似問題的左敌,可以聯(lián)系我一起探討瘾蛋。