views:

354

answers:

2

Hi,

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

+2  A: 

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.

Brad Larson
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
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
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
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
Can you please keep me updated on the status of this? Thank you so much.
nununo
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
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
A: 

I'm trying to link with the static lib compiled with the CHDataStructures-iPhone.xcodeproj but I get missing symbols link errors for "_objc_memmove_collectable", which seems to be referenced from CHDoublyLinkedList and CHListStack (probably some more classes but these are the ones I use).

Building the static lib xcode target from the xcode project works without errors, but the errors arise up when linking to the lib in my own project, or building the unit tests targets.

I'm building for SDK 3.1.2 and 3.2.3.

Have their been any changes in later SDKs that causes these problems?

niblha