[英]ARC Weak References when building message error
當我在 iOS 中使用 Capacitor 構建我的 Ionic 應用程序時,出現此錯誤:
ARC 弱引用 - 無法使用手動引用計數在文件中創建弱引用
該錯誤似乎來自 Cordova 插件,但我使用了電容器。 我多次嘗試重新安裝環境和項目,但自一周以來仍然被阻止。 非常感謝
我有完全相同的錯誤,我是這樣修復的:
這取決於您的構建結果,但在那之后,我不得不在 CordavaPlugins 文件中替換值的類型。 它是“__weak ....”,我替換為“__strong ....”。
第一次,我從這里走: https : //stackoverflow.com/a/62679942/1979190
但是這種方式會導致許多問題,如EXC_BAD_ACCESS
因為某些 Cordova 插件不支持這種方式。
我的隊友找到了解決此問題的方法。 根本原因來自電容器,我不知道他們為什么將Compiler flags
設置為-fno-objc-arc
所有來自CordovaPlugins
文件。
我們只需要像下圖一樣將Compiler flags
恢復為empty
,以避免與ARC Weak References
相關的所有錯誤消息。
但是每次運行npx cap update
或npx cap sync
所有內容都將重置為-fno-objc-arc
^^。
因此,我們需要編寫一個腳本,在運行這些命令后,將CordovaPlugins
所有文件的Compiler flags
設置為empty
。
我們將在 Podfile ( ios/App/Podfile
) 下面添加這個腳本來完成這項工作。
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['CordovaPlugins'].include? target.name
target.build_phases.each do |build_phase|
if (build_phase.display_name.eql? "Sources")
build_phase.files.each do |file|
if (file.settings)
settings = file.settings
settings["COMPILER_FLAGS"] = ""
file.settings = settings
end
end
end
end
end
end
end
希望有幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.