Can't find type xxx in scope
在程式中,常常會愈遇到 Can’t find type ‘XXX’ in scope 的錯誤,發生原因通常是
- 拼字錯誤或大小寫不一致
- 型態宣告不對
- 未加入complie source中
這次遇到的問題為第三點,再新增加一個class後,檢查命名與型態都正確時,還是無法解決此錯誤.
後來發現我在Project增加了兩個Target,第一個Target可以正常執行,而第二個Target卻會顯示錯誤.
於是檢查一下.xcodeproj, 此Taget的Build Phases,發現此class未加入compile source中,將此class加入進去即可解決此錯誤.
Can't find type xxx in scope
https://nickcarter9.github.io/2021/04/08/2021/2021_04_08-add_compile_source/