Xcode #import not finding .h file

13,060

Solution 1

Assuming that you also added Fraction.m to the project,

In the Group & Files view, select Fraction.m

Show the Editor view (Menu-->View-->Zoom Editor Out)

Select the Detail tab. There you should (again) see the Fraction.m file.

At the far right of the column there is a tiny target symbol. Make sure that column has a checkmark.

That ensures that your class Fraction is included when Xcode builds the app.

Solution 2

It happened the same to me, what I did was this:

1.- Click @ the "Show the project navigator" tab.

2.- Select your program's folder, the same that contains your main file, ie. "Program 1"

3.- In that same tab, go to the left bottom of the screen, there are 4 signs and a search window. Click on the icon on the left, the one with a "+" sign (add a new file).

4.- From the rollup window, select: "Add files to program..." .

5.- A new finder window appears, look for the files you want to add, (.h and .m for example) Click the "Add button"...

Voila!

Note that the files you are adding MUST be in the same folder as your main file, otherwise you'll have problems when compiling.

Hope this helps.

Share:
13,060
jag
Author by

jag

Updated on August 21, 2022

Comments

  • jag
    jag over 1 year

    I'm trying to import a .h file from an old xcode project into my current one. The file location is the same as the other files in the project (I moved it there), but after using #import in my program body file, when I try to run the program I get the following fail:

    "_OBJC_CLASS_$_Fraction", referenced from:

    objc-class-ref-to-Fraction in 9.1main.o

    ld: symbol(s) not found collect2: ld returned 1 exit status

    Does anyone know how to fix this? Thanks!

  • jag
    jag almost 13 years
    Of course! Actually I forgot the .m file entirely; I had been at it way too long... thanks for your help!