I'm on the latest beta version of Xcode (Xcode 4.5 with iOS 6.0). I've got an xcode project for an iphone app and I want to add a Unit Test target on it. I've followed carefully the instructions given on this page but I can't run the tests. Here's the message I read in the console:
Failed to find SDK: '6.0'
error: failed to attach to process ID 0
The target corresponding to the main application runs perfectly well on the iPhone 6.0 simulator though.
Where can I have made a mistake?
The easiest way to add a unit test target to your project is to select the Include Tests checkbox when you create the project. Selecting the checkbox creates targets for unit tests and UI tests. To add a unit test target to an existing Xcode project, choose File > New > Target.
⌘U will build and run all your test cases. It is the most commonly used shortcut when creating unit test cases. It is equivalent to ⌘R (build & run) while doing app development. You can use this shortcut to build your test target and run all the test cases in your test target.
To create a unit test, you will be subclassing a thing called an XCTestCase. Test cases have two methods you override to set your tests up and to tear your tests down when they are finished running. We will go over that in more detail later, but the basic idea is to create a nice clean slate before you run every test.
Use the XCTest framework to write unit tests for your Xcode projects that integrate seamlessly with Xcode's testing workflow.
Xcode -> Preferences -> Locations -> Command Line Tools => Select the one matches with SDK.
EDIT:
EDIT 2: For some people, the above method works. If not, please try:
It seems that this issue was a result of switching between more than one version of SDKs, and could be solved by specifying the current SDK as the active one with a terminal command(, which requires root privilege):
$ sudo xcode-select --switch <path-to-your-current-xcode.app>
I found that in order to get Xcode to attach to my unit tests, I had to use LLDB, GDB did not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With