How to organize unit testing of a library project in Xcode?

I'm not a fan of integrated development environments yet, but I'm trying to overcome my prejudices and learn about Xcode. (Eclipse / CDT is next, I couldn't get this to work for me when I tried last year, but this is a separate issue.)

I am writing new code in a new project that will become (part of) a small library. I want to unit test it too. How to explain to Xcode that I am creating a (shared) library, but I also want to use it in a test program compiled from a separate source that will not be in the shared library?

Source:

  • atom.c
  • atom.h
  • test atom.c

Produced Files:

  • libatom.dylib
  • test atom

I have atom.cand atom.hcompiled into a library. I'm just not sure how to organize things so that I can also build test-atomto link to the library. I assume that when I have it sorted by adding a library for testing support code, test-atom.c will be relatively straightforward - although it is not yet under Xcode control.

FWIW, I mainly work in C, not Objective C.

+5
source share
2 answers

You need two goals in your project; the target in Xcode creates a product that is a library, executable, or some other output.

, libatom.dylib, , , , test-atom .

, test-atom, test-atom.c libatom.dylib test-atom. - , , // . (, , , , .)

libatom.dylib test-atom. , test-atom libatom.dylib.

, test-atom ( ) "", libatom.dylib. , test-atom libatom.dylib.

+4

: . Xcode 3 Objective-C ( , , ). . unit test Objective-C? Obj-C, C, OCUnit , IDE.

+2

All Articles