Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Test target doesn't run on Xcode 4.5

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?

like image 890
pierroz Avatar asked Jul 27 '12 13:07

pierroz


People also ask

How do I create a test target in Xcode?

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.

How do I run unit test in Xcode?

⌘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.

How do I run a unit test case in Swift?

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.

Which framework is used to write unit test cases in Xcode?

Use the XCTest framework to write unit tests for your Xcode projects that integrate seamlessly with Xcode's testing workflow.


2 Answers

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>
like image 180
ZhangChn Avatar answered Oct 09 '22 17:10

ZhangChn


I found that in order to get Xcode to attach to my unit tests, I had to use LLDB, GDB did not work.

like image 43
Lynn S Avatar answered Oct 09 '22 18:10

Lynn S