2

I am trying to do this, and running into problems. The parent project needs to access the class SettingsViewController from the child project. I have put the child project path into my header search paths. Everything compiles OK, but I get linker errors, as follows:

Undefined symbols: "_OBJC_METACLASS_$_SettingsViewController", referenced from: _OBJC_METACLASS_$_StatisticsViewController in StatisticsViewController.o "_OBJC_CLASS_$_SettingsViewController", referenced from: objc-class-ref-to-SettingsViewController in SelectionViewController.o _OBJC_CLASS_$_StatisticsViewController in StatisticsViewController.o ld: symbol(s) not found collect2: ld returned 1 exit status

How can I fix this?

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
William Jockusch
  • 26,513
  • 49
  • 182
  • 323

4 Answers4

2

I assume the child project is a static library. Currently, your parent project knows how to find the header files of the child project (otherwise it wouldn't compile), but it doesn't know that it has to link to the library (.a) file of the child project.

You should probably add the library file to Targets > {your app} > Link Binary with Libraries. Furthermore, you probably need to add the linker flags -ObjC and possibly -all_load.

There are many detailed descriptions on the net, e.g. Build iPhone static library with Xcode.

Update:

If it's not a static library, then it's a rather strange project setup. The best thing you can do is to add the shared files (.h and .m) to both projects. They will then be independently compiled in both projects. That should work if you have few shared files.

But I recommend anyway to use a project setup with a static library. It nicely works if you properly set it up. I'm successfully using it. And - as I've told before - there a several good descriptions on the net how to set it up.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Codo
  • 75,595
  • 17
  • 168
  • 206
0

I know this is very old but might be helpful for others.

You need to setup the included project in Target Dependencies in "Build Phases" to get the included projet to be compiled and you also should add the static library of the included project in the "Link Binary with Libraries".

Click on your Target->Build Phases and set these up.

rydgaze
  • 1,050
  • 13
  • 24
0

You may be missing a framework. Can't really tell from what you have posted here though.

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • What additional information should I post to make it clear? And if I am missing a framework . . . from the parent project, or the child? – William Jockusch Dec 25 '10 at 03:40
0

Undefined symbols

Undefined symbols is a linker error

1.Check if you have added a library or framework

Project editor -> select a target -> General -> Frameworks, Libraries, and Embedded Content(Linked Frameworks and Libraries)
//or
Project editor -> select a target -> Build Phases -> Link Binary With Libraries

2.If you try to use Swift code from Objective-C

Add empty .swift file to the Objective-C project. When Xcode ask press Create Bridging Header

yoAlex5
  • 29,217
  • 8
  • 193
  • 205