'Person.h' file not found


#1

Folks-

I’ve rebuilt this project a couple of times, and restarted XCode a few times as was suggested on various bulletin boards, as a solution for when Class files aren’t found. However, even though the editor autocompletes instance methods in the class file and ‘Person.h’ in the main.m file, it throws the error described in the subject line. I have followed the directions as to adding files to the project.

header file:

[code]// Copyright © 2012 MyCompanyName. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface Person : NSObject
{

float heightInMeters;
int weightInKilos;

}

-(void)setHeightInMeters:(float)h;
-(void)setWeightInKilos:(int)w;

-(float)bodyMassIndex;

@end
[/code]

class file:

[code]// Copyright © 2012 MyCompanyName. All rights reserved.
//

#import “Person.h”

@implementation Person

-(void)setHeightInMeters:(float)h
{
heightInMeters = h;
}

-(void)setWeightInKilos:(int)w
{
weightInKilos = w;
}

-(float)bodyMassIndex
{
return weightInKilos/ (heightInMeters * heightInMeters);
}

@end
[/code]

and main.m - w/o any code currently, because I’ve rebuilt it a few times!

[code]// Copyright © 2012 MyCompanyName. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <Person.h>

int main (int argc, const char * argv[])
{

@autoreleasepool {
    
    // insert code here...
    NSLog(@"Hello, World!");
    
}
return 0;

}[/code]

Any help is appreciated!

Thanks,

Ralph


#2

Your project is a directory that you can look in using Finder.

Do you see a file called “Person.h” in that directory?


#3

Thanks for your reply. The folder structure is as follows:

BMITime/person.h, person.m, BMITime.xcodeproj, BMITime (subfolder)
BMITime/BMITime/BMITime-Prefix.pch, BMITime.i, main.m

-RL


#4

In Xcode, rename “person.h” to “Person.h” and “person.m” to “Person.m”. Classnames (and the names of their files) should always be capitalized – I mean, if you want to be stylish.


#5

drat. I mistyped. the files are indeed capitalized: Person.h, Person.m

-and I do strive for stylishness.


#6

hence, the problem lies elsewhere. Going to try rebuilding the project again.

Sounds like others have this problem as well. Just found this link. Going to try what I can, though I’m not quite clear on all the tips:

stackoverflow.com/questions/5584 … pendancies


#7

fixed it. it was a corrupted project.xcodeworkspace file.

stackoverflow.com/questions/6355 … 62#6356862

shows how to delete it. Then I restarted, and it still showed the header file as missing, but once I ran it, the error disappeared.

cheers,

RL


#8

I noticed that you imported the header file in main.m using brackets:

I tried compiling my implementation of the challenge using #import with < > instead of " " and got the error: [color=#FF0000]‘StockHolding.h’ file not found[/color]

Everything was fine and dandy when I changed it back using " " instead of <>

By the way, what is the difference between these two ways of importing?


#9

The quotes (“StockHolding.h”) means "look in my project."
The angle brackets (<StockHolding.h>) means “look in the standard places.”


#10

I was having trouble with this as well. I ended up changing the lines in main.m:

// Give the instance variables interesting values
[person setWeightInKilos:96];
[person setHeightInMeters:1.8];

into dot notation to make it work that way:

person.weightInKilos = 50.0;
person.heightInMeters = 1.8;

It wasn’t until a chapter after that I realized that the syntesize command automatically creates the setWeightInKilos. :slight_smile:


#11

[quote=“AaronHillegass”]The quotes (“StockHolding.h”) means "look in my project."
The angle brackets (<StockHolding.h>) means “look in the standard places.”[/quote]
I think this would be good to mention in the next book as it is not something we would know without previous experience. I was able to infer this because I dragged my StockHolding.h file into the <> so it showed the entire path of the file, but I don’t think that is the best way to try and explicitly call the header.


#12

I am getting very frustrated with the minutia of this language! It’s almost as bad as English! :laughing:

Having always (Hey! This is my first attempt at any kind of C) seen “<” and “>” around the file name to import, that’s what I used around Person.h! [color=#FF0000]What[/color]? I’m supposed to read the book that closely?! Just because it was in bold?! :unamused: :blush:

So, I tried moving the files in the Navigation area. Quite easy, seems to be expected, allowed and approved in Xcode (notwithstanding the possibility of Xcode losing track…). Still no joy.
I decided that I had selected the wrong “BMITime” choice in the instructions, so I created a BMITime #2 and noticed that you can’t use “#” in a Product name. Wow! I actually learned something! :unamused: But this time I selected the BMITime 2 directory, instead of the BMITime 2 Product, before creating the new Person file. Then I noticed that I could also choose “Supporting Files” as a location… Long story short, the warning remained, just not for the reason I thought.

So, [size=115]a question:[/size] Is there a problem with the location of these types of files (assuming one uses quotation marks instead of brackets!) being: [ol]1. Outside the directory holding main.m
2. Inside the directory holding main.m
3. In the “Supporting Files” directory
4. Any other uniquely name directory[/ol] Thanks :slight_smile: