3

I'd like to separate reusable code in Xcode 4 as a separate project/library/something else. The reusable code in this case is a game engine, and the main project is a game itself. Idea is to make the game engine code easy to use in the future projects.

Xcode 4 lets me create a blank project or a static library for iOS. Which one would be preferred (or would something else work better?) under KISS principle? I just want to separate two logical set of files into two projects (it's ok if one is a child of another), and to be able to compile them at the same time. I don't have a need for obfuscation and I've heard that with a static library one has to worry for which architecture it was built for, which sounds like an overkill.

I feel that a blank project might be better way to go than the static library, but I don't have any practical experience with this. Any preferences and why?

Rudi
  • 2,450
  • 5
  • 26
  • 37

2 Answers2

2

I ended up going with the static library since that seems to be preferred way of doing this in Xcode 4. When it works, it works great, but took me a while to set it up properly - these two links were invaluable:

http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/

and

Compile, Build or Archive problems with Xcode 4 (and dependencies)

Community
  • 1
  • 1
Rudi
  • 2,450
  • 5
  • 26
  • 37
0

Just create two projects. Add the dependent project into the main project. The Click on the Main XCode Project, Go to the Build Phases Tab, Under the "Target Dependencies" section click + sign and add the second project.

Kunal Deo
  • 2,248
  • 2
  • 18
  • 27
  • Did that (project B is child of project A), which then let me add project B product as a dependency. I'm still not sure how to use classes from project B in project A - doing usual #import "ClassName.h" returns "No such file or directory" error. – Rudi Apr 12 '11 at 17:30
  • 1
    Oh I see. I forgot to mention that For iOS you cannot include dynamic libraries for your project. You can only include static library. See if it works on Mac Projects – Kunal Deo Apr 12 '11 at 23:14