2

I'm trying to write a simple game engine for iOS in Objective C and C++ using Xcode.

I've made a game project and a game engine project. The latter is added to the former as a subproject. The engine is also added as a target dependency and as a binary to be linked in the game project.

My engine uses CADisplayLink so I add QuartzCore.framework in the engine project's "Link binary with libraries list" (found in Build phases).

Now, when I try to build my game project (the project with the subproject), I get this error:

Undefined symbols for architecture i386: "_OBJC_CLASS_$_CADisplayLink", referenced from: objc-class-ref in libVoya-iOS.a

This error only happens when building from the game project - doing it from the engine project works fine. If I add QuartzCore.framework to the game project building works fine.

Can it really be true I have to specifically require frameworks that one of my target dependencies already have required? In this case: My engine (sub project) already links QuartzCore - is it really necessary to also do this in the projects using this engine? It feels like double work for no reason.

Or perhaps I've just completely misunderstood something? :)

dandan78
  • 13,328
  • 13
  • 64
  • 78

3 Answers3

10

Add QuartzCore framework to fix this issue.

Nithin M Keloth
  • 1,595
  • 1
  • 20
  • 37
1

I've now found the answer to my question and I'd like to share it.

Static libraries are nothing more than a grouping of the compiled versions of the library's source files. They do not include any libraries they themselves might depend on.

Fusing all dependencies together happens only when you build the actual executable in the very end. For this reason, your application should indeed link against your dependencies' dependencies.

As for the example in my question, that means that my game should link QuartzCore while my game engine should not (even though it is my GameEngine who is using it).

Learn more here:

Community
  • 1
  • 1
0

I believe this is because you're using a target dependency instead of linking against a precompiled library.

Josh The Geek
  • 1,203
  • 12
  • 24
  • Removing my game engine library from the list of target dependencies did not change anything. Realizing static libraries doesn't actually "contain" their dependencies solved the issue for me. Read my own answer for more info. – Rasmus Rønn Nielsen Sep 01 '13 at 16:37