0

I am trying to learn XCode and I am following an online course. They are telling to use the #import command to point to a header file. I follow the instruction to the letter and I get an error saying"no such file or directory" but the file is listed under classes and the spelling is identical. I wanted to included a screenshot but could not. Please help!

2 Answers 2

1

You are getting that error because Xcode cannot find the file you are trying to import.

Correct usage:

#import "RootViewController.h"

or

#import <Foundation/Foundation.h>

You also have to make sure that the file(s) you try to import are in your Project list. If the file you are trying to import is not in this list, then you will always receive this error.

alt text

Sign up to request clarification or add additional context in comments.

2 Comments

That worked. I was using <> not "". I switched it to "" and it worked like a charm. Thank you very much.
If the answer worked for you, click the Checkmark till it turns green, happy coding!
0

It is possible that the file has been renamed in XCode. When a file's name is changed in the XCode interface, it's actual name is no longer changed in the file system. It used to, but doesn't anymore. In order for the compiler to find the file, you have to use the path to the header in the file system. Make sure the files are in the same folder and use the name displayed by Finder.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.