Longshihua
Longshihua

Reputation: 425

" Linker command failed with exit code 1 " in unit test?

I setup the project by Xcode 8.2.1. I upgrade to Xcode 8.3.2. I can run the project and no error. But when I run the unit test to test my app , I got this problem:

enter image description here

I have tried some ways to solve it. For example: clean the Test host

enter image description here

Or remove the derivedData and clean the app. All of them weren't work for me. I don't known the reason why I got this error. Does anyone can help me? Thanks

Upvotes: 7

Views: 2631

Answers (4)

Markussen
Markussen

Reputation: 164

That happened to me too a couple of times after removing a pod.

I just clean the project (Product --> Clean (Build Folder)) and when rebuilding, the error message is gone.

Upvotes: 0

James Alvarez
James Alvarez

Reputation: 7219

If you are here because it seems that you can't see more details about this error, right click and select 'Reveal in Log'.

Upvotes: 0

CodeBender
CodeBender

Reputation: 36612

I just ran into the most unhelpful error ever while adding unit tests to an Xcode project.

The issue was that the Podfile was not updated to include a test target. I fixed it with the following steps:

First, get the name of your test target.

Next, update your Podfile with this:

  target '<YOUR_PROJECT>Tests' do
      inherit! :search_paths

      # Any pods that may be needed for testing
  end

Then, run pod install.

After that, I was able to build & run tests.

Your mileage may vary...

Upvotes: 1

Marijn
Marijn

Reputation: 1479

The Host Application on my Test Target was set to None for me the error was resolved when I set that to my Project Target

You can set that in this dropdown in the General tab on your project Target:

enter image description here

Upvotes: 8

Related Questions