Importing Classfiles creates errors


#1

Hi together,

my problem is very simple (at least I hope so).
When the book tells me to import a class, I always get the same two errors (with other classnames of course):

Undefined symbols for architecture i386:
"OBJC_CLASS_BNRItem", referenced from: objc-class-ref in BNRItemStore.o (maybe you meant: _OBJC_CLASS__BNRItemStore)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I really have no idea what causes these errors. When I create a new class instead and simply copy the old code into the new files, everything works fine.

I hope you have a solution for me :wink:

Have a nice day!
Joerg


#2

What the error is saying is that, somehow, the compiler could not find the *.m file containing the implementation of BNRItem class.
Are you creating your new projects from scratch or are you copying files from other projects?

Please create a toy project that has the the same kinds of errors, and post the files.


#3

"the compiler could not find the *.m file"
Thank you ! That was the info I needed. It turned out, that the Files were added to the project, but they were not added to the Target. So I got the Linking Error. Thanks again.

But for the future: How can I add Files to the Target, that are already in my project ?

Greetings
Joerg


#4
  1. Select the *.m file
  2. Show the Utilities pane (the window on the right side of Xcode)
  3. Select the first tab (File inspector)
  4. You will see a “Target Membership” section

#5

Thank You !!