X is not a member type of Y

后端 未结 6 1681
难免孤独
难免孤独 2021-02-13 05:36

I\'m having staring issues with Module name spacing in a swift project.

I\'ve tried this in a new project and everything works fine:

I have 2 modules with which co

6条回答
  •  执笔经年
    2021-02-13 06:05

    You likely have a class/struct/enum DataManager anywhere in your code which hides the DataManager module. The error states that it cannot find LocationManager in type DataManager where it should read module instead.

    Your app modules should be designed in a way so that you never need to explicitly use the module's name except for the import statement. So just use LocationMessage.Type directly without stating the module.

    This is one reason all our app's modules are prefixed with an X, e.g. XDataManager. This avoids conflicts with Apple's modules, external modules (like from CocoaPods) and with types (like in your case).
    The X also makes it obvious that these modules are part of the app itself and not some third-party frameworks.

提交回复
热议问题