daniel
daniel

Reputation: 9825

iPhone XCode Unit test framework build settings

I am trying to add Unit Test to my project, here is what I am doing:

  1. Add target -> Cocoa Touch Unit Testing Bundle
    product: AuthyTests
    company Identifier:com.authy.com
    project: authy

    So the resulting bundler identifier is: com.authy.AuthyTests

  2. if I run command+U(Product -> test) it works unit tests are ran.

  3. Now I add a library from my project so #include "otp.h" AuthyTests.h

  4. Add some call to AuthyTest.m ([Otp foo];) and I get an error:


Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Otp", referenced from:
objc-class-ref in AuthyTests.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Things I've tried:

1.I tried adding authy.app as a dependency on TargetDependencies of AuthyAppTests Build Phases.

2.Targets -> AuthyTests -> BuildSettings -> Build Active Architechture Only -> Yes

I am using xcode 4.2. I also tried everything on this website:
http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/

What am I missing to set-up UnitTests on XCode?

Upvotes: 2

Views: 1070

Answers (1)

Michael Petrov
Michael Petrov

Reputation: 2307

It sounds like one of the steps from the tutorial hasn't been followed. Specifically, steps 4-6. My guess would be that the two settings for the bundle loader are off. One other possibility to try:

In your main Authy app target:

  • change the Architectures build setting to:
    • i386
    • armv6
    • armv7
  • also change "Build Active Architectures Only" to "No"

One of those should force the main Authy binary to have i386 in it. If that still doesn't work, then it is the bundle loader settings that are misbehaving.

Upvotes: 3

Related Questions