Why does XCode not recognize this header file
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 s开发者_开发技巧aying"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!
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.
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.
精彩评论