Skip to main content

googletest Xcode Tip

·1 min

Make sure your application’s C++ source files are members of the unit testing target you created. If you don’t add your application’s C++ files to the unit testing target, you will get linker errors when your unit tests access your application’s classes.

To add one of your application’s C++ files to the unit testing target, open the file’s inspector by selecting the file in the project window and clicking the Get Info button in the project window toolbar. Click the Targets tab in the inspector, which should have a list of your project’s targets with a checkbox next to each target. Select the checkbox next to the unit testing target.

FileTargetInspector.png

Alternatively, you can add a bunch of files to the unit testing target by clicking disclosure triangles in the Groups and Files list to expose the unit testing target’s build phases. Drag the C++ files to the unit testing target’s Compile Sources build phase.