3

I'm new to iPhone programming and I'm trying to use CHDataStructures in my project. But I'm running into some issues:

  1. When I directly try to build it right after download I get the error "Foundation/Foundation.h" no such file or directory. The Active SDK is "Use Base SDK" and the active architecture is x86_64. I believe I should set the Active SDK to the iPhone SDK but it isn't listed there;

  2. At some point (I don't remember how) I managed to tweak it and I got the iPhone SDK (simulator) in the active SDK but when I tried to build it I got the following error: "target specifies product type 'com.apple.product-type.framework', but there's no such product type for the 'iphonesimulator' platform";

And now I'm stuck. What am I doing wrong?

Thanks in advance, Nuno

Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
nununo
  • 223
  • 2
  • 11

1 Answers1

3

CHDataStructures is a framework that was written for the Mac. Frameworks are not used on the iPhone, static libraries are employed in their place. I'd suggest creating a new Cocoa Touch Static Library project, then adding all of the source files to that static library. None of the source files for the project appear to include Cocoa.h or other Mac-specific headers, so you should be able to get this static library to compile without too much fiddling.

There are several good questions on creating and using static libraries here, including the following:

For examples of static libraries out there, I'd direct you to the Three20 and Core Plot projects.


UPDATE: CHDataStructures now supports both a Mac framework and iOS static library.

Community
  • 1
  • 1
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • 1
    It occurs to me that a target to create a static library for iPhone would be a good addition to the Xcode project for my framework. I'll see if I can find some time to add that — if anyone cares to help out, I gladly accept contributions. :-) – Quinn Taylor Nov 04 '09 at 15:13
  • Hi Quinn, I just tried to add a Cocoa Touch target to your project and it does not seem to be trivial as some classes rely on the existence of `NSAllocateCollectable` (e.g. `CHDoublyLinkedList`), which the iPhone does not support. Other posts here on SO seem to suggest that your library does work on the iPhone but to me it seems it doesn't without modifications to the memory management code. Am I overlooking something? – Ole Begemann Nov 04 '09 at 16:30
  • It should be pretty easy to define a custom `NSAllocateCollectable()` for an iPhone static library which just does malloc underneath, like 10.4 does, and 10.5 when GC is not enabled. This could just go in code that is only included in that target. It's issues like this that make it seem worthwhile to include a target for this, so people don't have to reinvent the wheel just to use CHDataStructures on iPhone. – Quinn Taylor Nov 04 '09 at 17:16
  • Alright, I'll try to do it. This is the first time I am gonna do something like this so I can't promise anything, though. – Ole Begemann Nov 04 '09 at 17:27
  • Can you please keep me updated on the status of this? Thank you so much. – nununo Nov 08 '09 at 11:26
  • Hello nununo, I have been working with Quinn to include a static library and a unit testing target for the iPhone to the code. I am sure you can expect an update that includes all this to the repository shortly. – Ole Begemann Nov 08 '09 at 22:48
  • Sorry for the delay, this has now been done and committed to the repository. Ole helped quite a bit and we even have the unit tests running on the iPhone itself now. Please let me know directly if you experience any problems. Thanks! – Quinn Taylor Dec 10 '09 at 18:13
  • @Quinn Taylor, Hi Quinn, the download of CHDataStructures is down. Please have a look! – Jack Apr 03 '11 at 14:35