tomg101
tomg101

Reputation: 169

Error running Xcode Unit Tests from Command Line

I am trying to run my Xcode unit tests via command-line so I can eventually wire it to Jenkins for CI. The Workspace contains 2 projects:

CommonProject (shared libraries used for multiple apps)

MainProject

The MainProject uses libraries in the CommonProject, so there is a dependancy. Each project has its own separate xcodeproj file.

So I need to run my unit tests associated to the MainProject. I use this command to run the unit tests from Terminal in the Main Project Directory:

xcodebuild test -scheme MainProject -configuration Debug -sdk iphonesimulator7.0 -destination OS=7.0,name="iPad"

I get the following errors.

ld: warning: directory not found for option '-L/development/MainProject/../../../../Library/Developer/Xcode/DerivedData/MainProject-frbbgalqmolpaxcdmzssejnssluu/Build/Products/Debug-iphoneos'
ld: warning: directory not found for option '-F/development/MainProject/../../../../Library/Developer/Xcode/DerivedData/DTCoreText-fgbvjplplkeyyghcvrfbmvoetoiq/Build/Products/Debug-iphoneos'

ld: library not found for -lCommonProject
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** TEST FAILED **

The following build commands failed:
Ld /Library/Developer/Xcode/DerivedData/MainProject-bxpugeyjdgrcfcgxxpttwlgmfrma/Build/Products/Debug-iphonesimulator/MainProject.app/MainProject normal i386

Since the unit tests require the common project to run, it may not be able to find the files it needs since they are located in a separate directory. Has anyone had this issue before or have any ideas how I can resolve it?

Upvotes: 1

Views: 1312

Answers (1)

Patrick Hernandez
Patrick Hernandez

Reputation: 585

I have worked with this issue before and the solution was to ensure the generated library files were in the same location as the project.app file. Given this you need to point the CONFIGURATION_BUILD_DIR to a common location. You can use the argument below to accomplish this.

xcodebuild test -scheme myScheme -configuration Debug -sdk iphonesimulator7.0 CONFIGURATION_BUILD_DIR=$(PWD)/build

Upvotes: 1

Related Questions