Curnelious
Curnelious

Reputation: 1

Importing .mm file to another .mm file on xcode

I am getting error when trying to import .mm file to another one. Its build like that :

first class FailedMenuLayer is .mm and have in its .h :

#import "gameScene.h"

second class gameScene is .mm, and have in its .h :

#import "FailedMenuLayer.h"
   FailedMenuLayer *menuGO; //here i get the error: unknown type FailedMenuLayer .

why is that ?

Upvotes: 2

Views: 1493

Answers (2)

SinzianaG
SinzianaG

Reputation: 174

It looks like an import cycle.

One way to fix it is to move the "gameScene.h" import to the .mm file. It's actually a good practice to keep the imports in the .h file limited only to what you actually need in the header and keep everything else in the .mm file.

If you need the import in the header try using @class instead of #import;

@class gameScene;

Don't forget to import gameScene.h in the .mm file also.

Upvotes: 2

Nikita P
Nikita P

Reputation: 4246

you are not importing ".mm" file, you are importing it's header.

Check your build phases> compile sources for your .mm file to be listed there. That might be your issue

Upvotes: 0

Related Questions