"No such file or directory" error

Discussion in 'iPhone/iPad Programming' started by BirdInTheCity, Apr 19, 2009.

  1. macrumors newbie

    Joined:
    Feb 12, 2008
    #1
    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. macrumors 68010

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

    Joined:
    Sep 5, 2006
    #3
    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. macrumors newbie

    Joined:
    Apr 16, 2009
    #4
    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. thread starter macrumors newbie

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

    Thanks!
     
  6. macrumors 68010

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

    Joined:
    Jun 16, 2009
    #7


    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