Swift: Use of undeclared type

2019-07-05 02:57发布

I'm implementing a class but I'm getting this error:

Use of undeclared type 'myProtocol'

Here is my code:

class LocalContactService: myProtocol{

Any of you knows why I'm getting this error?

5条回答
聊天终结者
2楼-- · 2019-07-05 03:34

I my case I had to clean the build folder, close the project, run pod install, and then the issue disappeared.

查看更多
Summer. ? 凉城
3楼-- · 2019-07-05 03:43

i had the same error .in my case i found accidentally that i added my swift files into "copy bundle resource" in "build phase" i removed all swift file except assets then everything worked fine.

enter image description here

查看更多
唯我独甜
4楼-- · 2019-07-05 03:43

Perhaps you've never defined myProtocol. Or if you have, maybe it's out of scope in the LocalContactService class

查看更多
男人必须洒脱
5楼-- · 2019-07-05 03:48

I got this error when someone pushed changes that they made to the project.pbxproj file.

Select the file hit delete and choose the option to Remove Reference

Add the file back to the project, clean (cmd + shift + k), and rebuild

查看更多
虎瘦雄心在
6楼-- · 2019-07-05 03:54

Go to your myProtocol class, and on the right side (If you are using XCode), click the Tests of your class. This is what I mean.

"Use of undeclared type" in Swift, even though type is internal, and exists in same module

查看更多
登录 后发表回答