I’m trying to write unit tests in Xcode (7.0.1). I’m aware that Juce has its own unit testing capabilities, but I want to leverage the built-in tooling capabilities of Xcode. This worked prior to my upgrade to Juce 4.2.
As a test, I created an empty Audio Application from Projucer, opened the Xcode project, and added my test target. This creates a file called TestProjectTests.m, which is an Objective-C file. In order to use some Juce classes in my unit tests, I
#include "JuceHeader.h", and so I also have to change the file extension to TestProjectTests.mm, which permits mixed Objective-C and C++ content in the same file.
Now I run the test, and I get a build error:
/Users/Tom/Documents/Programming/TestProject/JuceLibraryCode/JuceHeader.h:18:10: 'juce_audio_basics/juce_audio_basics.h' file not found.
The next thing I tried is to add the Juce modules to the header search paths for my test target, exactly like they are in the App target:
../../JuceLibraryCode ../../../JUCE/modules. Now, when I run the tests I get a linker failure:
ld: file not found: /Users/Tom/Library/Developer/Xcode/DerivedData/TestProject-aqkriarcaprkccbjfvtdkacnwhif/Build/Products/Debug/TestProject.app/Contents/MacOS/TestProject clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have a feeling I’m missing something simple, but I’m clueless as to what to try next. Thoughts? Thanks!!
Edit: I also tried specifying the “User Search Paths” for the test target. This got me a raft of errors in JuceHeader.h, of the flavor:
/Users/Tom/Documents/Programming/TestProject/JuceLibraryCode/JuceHeader.h:18:10: 'juce_audio_basics/juce_audio_basics.h' file not found with <angled> include; use "quotes" instead
Edit #2: I’ve isolated this down further, reproducible with the following steps:
1: Create an empty Audio Application from Producer
2: Open the Xcode project
3: Add a test target
4: Try to run the tests, get the linker error.