You might think you were in luck when Xcode offered you an option to migrate to XCTest, but shortly after trying you will discover that this isn't a true migration. Xcode will only migrate your code, it will not update your project to be testable with XCTest. There are still some steps left and unfortunately Apple have not shared any documentation on how to do this.
I have later discovered that it does work as expected, but only if you run the conversion from a project directly. If you try running the conversion from a workspace you will get the problems mentioned above. I have filed this as rdar://16581037 so Apple can fix this in the future. For now, you'll need to follow the below steps.
You can follow these steps to migrate your project to XCTest once you've migrated the code with the automatic converter:
- Change the Wrapper Extension your project's test target in build settings from ocunit to xctest.
- This is the scary part, you are going to need to manually edit your Xcode project by hand and replace the product type for your test target. Firstly, close Xcode and then open the project's project.pbxproj in your favourite text editor and search for the product type. You will need to change it from com.apple.product-type.bundle to com.apple.product-type.bundle.unit-test.
productReference = 77DC06B215702EDB0001EF8C /* PalaverTests.xctest */ -productType = "com.apple.product-type.bundle"; +productType = "com.apple.product-type.bundle.unit-test";
- Remove the OCUnit Run Script build phase from your project's test target.
- Replace SenTestingKit framework with XCTest inside the test target's link with libraries build phase. Even better, you can clean up your project by enabling modules instead of adding XCTest.
For iOS, you may need to add the SDK's developer frameworks so the linker can find the XCTest framework for iOS when building the project.
You will need to add $(SDKROOT)/Developer/Library/Frameworks to the framework search paths for the test target.
If you are using Kiwi, be sure switch to the XCTest pod.