0

I have written a static library to re-use some code between iOS projects, let's call it MyLib.

While MyLib has good unit test coverage, it interacts heavily with external resources, and I'd like to make sure that it does the right then when it's hooked up with other pieces of an actual application. In short, I would like to add an application test target to my static library in addition to the unit test target. No drama there.

In thinking about the general setup, I also wondered if it wouldn't be a good idea to ensure that my library's application test target linked against the actual libMyLib.a binary artifact, thereby putting that step of the process under test as well.

So two questions:

  1. Is this even necessary? Is there any significant risk that the final libMyLib.a binary product could behave differently than the series of compiled .m files that my unit tests already exercise? (Possible answer would be that it guards against the accidental exclusion of one of those .m files in the eventual build target).

  2. How would one make certain that the application test target was linking against libMyLib.a? Is this configurable within the build settings? Is any custom build scripting necessary?

I apologize in advance for the basic question if this is common knowledge, I'm slowly coming up to speed on build process, linking, etc. in general, not just how it is implemented using Apple's SDKs.

prairiedogg
  • 6,323
  • 8
  • 44
  • 52

1 Answers1

0

This is actually accomplished fairly easily. In your static library's project:

(Assumes XCode 3)

  1. Create a new application target.
  2. "Get Info" on the application target to edit its properties.
  3. Click the "General" Tab at the top
  4. Click the "+" button under the "Direct Dependencies" pane, add your static library build target. This will build the static library BEFORE you build the new application target.
  5. Click the "+" button under the "Linked Libraries" pane, add libMyLib.a (or whatever your library is called)

Your project should now link against the actual built artifact.

prairiedogg
  • 6,323
  • 8
  • 44
  • 52