PDA

View Full Version : "No such file or directory" error




BirdInTheCity
Apr 19, 2009, 11:10 PM
I'm trying to follow the Stanford iPhone class and am having a problem with the import command. <-- Total n00b question

Basically, I have a implementation file called "WhatATool.m" and we were told to create a custom class called "PolygonShape".

I did just that, via New File... > Objective C Class >
I set the file name as "PolygoneShape.m"
Kept the box checked to create the header file
Kept the box checked to Target "WhatATool"

And then at the top, right next to #import <Foundation/Foundation.h>, I put the line #import <PolygonShape.h>. But when I try to compile it, it says:
"error: PolygonShape.h: No such file or directory"

Why can't it find it? Do I have to do anything else to get it to work? The .m and .h files are both listed under the "source" folder on the left.

I assume that it's got to be something stupid and small... but I just can't figure out what's going on. Structurally, all these files are in the same directory. Any thoughts?



CocoaPuffs
Apr 20, 2009, 03:25 AM
I'm trying to follow the Stanford iPhone class and am having a problem with the import command. <-- Total n00b question

Basically, I have a implementation file called "WhatATool.m" and we were told to create a custom class called "PolygonShape".

I did just that, via New File... > Objective C Class >
I set the file name as "PolygoneShape.m"
Kept the box checked to create the header file
Kept the box checked to Target "WhatATool"

And then at the top, right next to #import <Foundation/Foundation.h>, I put the line #import <PolygonShape.h>. But when I try to compile it, it says:
"error: PolygonShape.h: No such file or directory"

Why can't it find it? Do I have to do anything else to get it to work? The .m and .h files are both listed under the "source" folder on the left.

I assume that it's got to be something stupid and small... but I just can't figure out what's going on. Structurally, all these files are in the same directory. Any thoughts?
#import "PolygonShape.h" in your .m.

:: ultranol ::
Apr 20, 2009, 06:06 AM
I'm new to the subject and yesterday I went throught just what you said.

In addition to doing the #import thing on your WhatATool.m file, you have to declare the class in the WhatATool.h file, before the @implementation clause:

@class PolygonShape;

This worked for me, I hope it works for you too.

thomasjt
Apr 20, 2009, 06:53 AM
I actually found that I had to provide the full path - not sure why, since the PolygoneShape.h file is right there in the freaking directory...

BirdInTheCity
Apr 20, 2009, 08:05 AM
#import "PolygonShape.h" in your .m.

YUP! That was it! I knew it was something small. I needed quotes around the PolygoneShape.h instead of the <>.

Thanks!

CocoaPuffs
Apr 20, 2009, 01:51 PM
I actually found that I had to provide the full path - not sure why, since the PolygoneShape.h file is right there in the freaking directory...

That's only if you are creating an ivar of that class.

etalmor
Jun 16, 2009, 04:50 AM
I'm trying to follow the Stanford iPhone class and am having a problem with the import command. <-- Total n00b question

Basically, I have a implementation file called "WhatATool.m" and we were told to create a custom class called "PolygonShape".

I did just that, via New File... > Objective C Class >
I set the file name as "PolygoneShape.m"
Kept the box checked to create the header file
Kept the box checked to Target "WhatATool"

And then at the top, right next to #import <Foundation/Foundation.h>, I put the line #import <PolygonShape.h>. But when I try to compile it, it says:
"error: PolygonShape.h: No such file or directory"

Why can't it find it? Do I have to do anything else to get it to work? The .m and .h files are both listed under the "source" folder on the left.

I assume that it's got to be something stupid and small... but I just can't figure out what's going on. Structurally, all these files are in the same directory. Any thoughts?



Hi - I solved this by deleting the #import <Cocoa/Cocoa.h> on PolygonShape.h .

I figured since Cocoa.h is already imported in the Controller class, it's ok to omit this.
Neither the full path nor the "" things worked for me, only this.