Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

X is not a member type of Y

Tags:

xcode

swift

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 contain the same class name and i'm able to reference the class from Module.Class no problem.

I have an existing swift project and I'm unable to get this working. I keep getting the error

enter image description here

So as you can see if I don't try to Module-Scope the class everything works fine.

(And yes i've tried with and with out the .Type addition).

So I'm assuming there is something off in my compiler setting. The only other thing I can think of is that my LocationMessage class is defined not in the main DataManager "class" file but rather in a different file.

But I really can't make heads or tails of whats going on. Any suggestions?

Project Structure

Framework: DataManager

  • DataManager.swift
  • LocationMessages.swift

Framework: ReferenceTest

  • File.swift

So my issue is that in File.swift I'm trying to reference a class defined in LocationMessages.swift inside the DataManager.framework The class IS public

@objc(DMLocationMessage)
final public class LocationMessage : ParsedMessage {
like image 447
Jeef Avatar asked Dec 08 '15 15:12

Jeef


2 Answers

There is also this bug in swift compiler: SR-631 Extensions in different files do not recognize each other

The result (success/failure) of the compilation depends on the order of files in Build Phase > Compile Sources setting.

I had exactly the same error message: X is not a member type of Y. Solved it by rearranging compilation sources.

like image 177
Anton Avatar answered Oct 11 '22 17:10

Anton


In case anyone is here while trying to build and use an xcframework, apparently, the issue is caused when you have a class in the framework which has the same name as the module/framework.

This is a known issue and needs a workaround as mentioned here.

P.S. - I know this doesn't answer this question per se. Just leaving it here for anyone else who might land here because of the question title.

like image 38
Derryl Thomas Avatar answered Oct 11 '22 17:10

Derryl Thomas