When writing my test cases for my current objective-c project I noticed a lot of common functionality and class variables in a sub-set A of my test cases. I therefore wanted to subclass the XCTestCase class once, lets call the new class ExtendedXCTestCase, and let that one class contain all the mentioned class variables and common methods, and then simply let the sub-set A each subclass the ExtendedXCTestCase class, to allow for access to the common methods and variables without duplicating code.
Although this is apparently harder than it seems, as I keep getting
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: 2 duplicate symbols for architecture x86_64
If creating a new test target and then create the ExtendedXCTestCase class inside that target followed by creating a new test class, which is a subclass of ExtendedXCTestCase instead of XCTestCase, is enough to cause the problem, even without adding any more code to the two generated files, aside for the ExtendedXCTestCase import (when created through Xcode).
I tried searching around on the great Internet for a while with no luck at all.
An easy fix would be to create a utility class that contains the common variables and methods and simply let each test case subclass XCTestCase, but then just use that object. But I want to be able to subclass XCTestCase, is this just not possible, or have I missed something vital?
Any help is appreciated, thanks in advance.
The full error transcript for the new target is as followed:
Ld /Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build/Products/Debug/TODO\ Tests.xctest/Contents/MacOS/TODO\ Tests normal x86_64
cd /Users/Arni/Desktop/TODO_List_project/TODO_List
setenv MACOSX_DEPLOYMENT_TARGET 10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -L/Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build/Products/Debug -F/Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build/Products/Debug -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build/Intermediates/TODO_List.build/Debug/TODO\ Tests.build/Objects-normal/x86_64/TODO\ Tests.LinkFileList -mmacosx-version-min=10.9 -bundle_loader /Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build/Products/Debug/TODO_List.app/Contents/MacOS/TODO_List -framework XCTest -fobjc-arc -fobjc-link-runtime -framework XCTest -Xlinker -dependency_info -Xlinker /Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build/Intermediates/TODO_List.build/Debug/TODO\ Tests.build/Objects-normal/x86_64/TODO\ Tests_dependency_info.dat -o /Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build/Products/Debug/TODO\ Tests.xctest/Contents/MacOS/TODO\ Testsduplicate symbol _OBJC_CLASS_$_TODOExtendedXCTestCase in:
/Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build /Intermediates/TODO_List.build/Debug/TODO Tests.build/Objects-normal/x86_64/TestTODOItem.o
/Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build /Intermediates/TODO_List.build/Debug/TODO Tests.build/Objects-normal/x86_64/TODOExtendedXCTestCase.o duplicate symbol _OBJC_METACLASS_$_TODOExtendedXCTestCase in:
/Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build /Intermediates/TODO_List.build/Debug/TODO Tests.build/Objects-normal/x86_64/TestTODOItem.o
/Users/Arni/Library/Developer/Xcode/DerivedData/TODO_List-fcuqkpfqvjdtiscxnapifzxzbgrq/Build /Intermediates/TODO_List.build/Debug/TODO Tests.build/Objects-normal/x86_64 /TODOExtendedXCTestCase.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)