Add a C++ function that can be used by multiple XCTest files in Xcode

I'm testing a c++ project. I would like multiple XCTest files to be able to use this function:

void testGLMVEC3(const glm::vec3& actual, const glm::vec3& expected)
{
    XCTAssertEqualWithAccuracy(actual.x, expected.x,  0.00001f);
    XCTAssertEqualWithAccuracy(actual.y, expected.y,  0.00001f);
    XCTAssertEqualWithAccuracy(actual.z, expected.z,  0.00001f);
}

I'm not sure how to do this. I don't think I should put this function in my project code. I'd like it to be in my XCTest files. (I wouldn't know how to put it in my project code anyhow.) Here's how I'd expect to use it:

#import <XCTest/XCTest.h>
#import "../OrangeSpider/SpLeftLeg.hpp"
...

@interface SpLeftLegTest : XCTestCase
@end

@implementation SpLeftLegTest

- (void)setUp {}

- (void)tearDown {}

- (void)testGetPoints{
    
    // Set up
    float topLength       = 10.0f;
    ...
    
    // Actual SpLeftLeg
    SpLeftLeg spiderLeg{spLegAnatomy, spLegAngles, minExtensionAngles, maxExtensionAngles};
    
    // Test points
    testGLMVEC3(spiderLeg.getConnectionPoint(), glm::vec3(0.0f, 0.0f, 0.0f));
    
}

- (void)testPerformanceExample {
    [self measureBlock:^{
    }];
}

@end

This works. There is a question at the end. I added a Utilities.hpp file in my XCTest folder, "TestsOrangeSpider" (separate from my project code.)

#ifndef Utilities_hpp
#define Utilities_hpp
#import <XCTest/XCTest.h>
void testGLMVEC3(const glm::vec3& actual, const glm::vec3& expected);
#endif

In the same folder I have a Utilities.cpp file.

#include "Utilities.cpp"
void testGLMVEC3(const glm::vec3& actual, const glm::vec3& expected)
{
    XCTAssertEqualWithAccuracy(actual.x, expected.x,  0.00001f);...
}

In one of my test files I import the .cpp file. In all other test files I import the .hpp file. Importing the .cpp file in all test files doesn't work. Importing the .hpp file in all test files doesn't work. It has to be one file imports the .cpp and all other files import the .hpp. Why is there this odd combination requirement? Thanks : )

Add a C&#43;&#43; function that can be used by multiple XCTest files in Xcode
 
 
Q