"No such file or directory" error

Discussion in 'iOS Programming' started by BirdInTheCity, Apr 19, 2009.

  1. BirdInTheCity macrumors newbie

    Feb 12, 2008
    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?
  2. CocoaPuffs macrumors 68010

    Aug 23, 2008
    #import "PolygonShape.h" in your .m.
  3. :: ultranol :: macrumors newbie

    Sep 5, 2006
    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.
  4. thomasjt macrumors newbie

    Apr 16, 2009
    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...
  5. BirdInTheCity thread starter macrumors newbie

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

  6. CocoaPuffs macrumors 68010

    Aug 23, 2008
    That's only if you are creating an ivar of that class.
  7. etalmor macrumors newbie

    Jun 16, 2009

    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.

Share This Page