12

I'm trying to add tests to a mac app. I'm using XCTest framework. When i run tests (cmd + U) i receive "Test failed" and in console I see :

2013-10-15 13:22:56.354 8tracks Radio[40560:303] Error loading /Users/victor/Library/Developer/Xcode/DerivedData/Musica-dhxbqwburbddtietormguodcwoqt/Build/Products/Test/MusicaTests.octest/Contents/MacOS/MusicaTests:  dlopen(/Users/victor/Library/Developer/Xcode/DerivedData/Musica-dhxbqwburbddtietormguodcwoqt/Build/Products/Test/MusicaTests.octest/Contents/MacOS/MusicaTests, 262): no suitable image found.  Did find:
/Users/victor/Library/Developer/Xcode/DerivedData/Musica-dhxbqwburbddtietormguodcwoqt/Build/Products/Test/MusicaTests.octest/Contents/MacOS/MusicaTests: open() failed with errno=1IDEBundleInjection.c: Error loading bundle '/Users/victor/Library/Developer/Xcode/DerivedData/Musica-dhxbqwburbddtietormguodcwoqt/Build/Products/Test/MusicaTests.octest'

Any ideas? Cheers!

Abizern
  • 146,289
  • 39
  • 203
  • 257
Tatarasanu Victor
  • 656
  • 1
  • 7
  • 19

3 Answers3

12

You need to disable code signing in order to run unit tests. This page explains how to create a configuration for testing so that your debug and release applications are code signed but your unit tests are not. Don't forget to do a full clean after changing the configuration.

Benjamin Smith
  • 315
  • 2
  • 4
  • +1 absolutely correct, but only if you are getting "errno 1" (Operation Not Permitted). I had quite a bit of work to do to allow my sandboxed app to run in non-sandboxed mode during unit-testing. – trojanfoe Feb 11 '14 at 14:32
  • This solved the problem for me using Xcode 5.1 on 10.9.2 – Craig Otis Apr 02 '14 at 11:51
  • This worked for me. I also used [RB App Checker Lite](http://brockerhoff.net/RB/AppCheckerLite/) to check that my non-test release was still signed correctly. – Ashley Jun 22 '14 at 15:29
  • Also: note that the final configuration, made within the scheme editor, seems to be stored in PROJECT.xcodeproj/xcuserdata/USERNAME.xcuserdatad/xcschemes/PROJECT.xcscheme. I don't have this saved in my source control, so the error returned when I started using a newly checked out working copy. The fix is to repeat the last stage of the setup. – Ashley Jul 21 '14 at 15:11
  • 3
    Xcode 6.1 seems to require that both the test target and the app container be signed. – Ben Flynn Nov 14 '14 at 20:34
  • 1
    This answer is now wrong. Xcode 6.1+ requires both to be code signed. – Claus Jørgensen Feb 20 '15 at 00:14
5

I had the same "no suitable image found" issue when was trying to add tests to an existing ios project. Try to go to Build Settings of your Tests target and set "Build Active Architecture Only" to "No". This solved my issue.

Also, make sure you have the same Architecture for both targets or you'll get strange linker errors.

mekarthedev
  • 130
  • 7
  • Same problem for me when I convert application testings from SenTests to XCTest. Logic test were okay. Saved a lot of time. – karim Nov 10 '14 at 08:58
0

I was facing a different issue but was seeing the same log. For the problem was that the deployment target of the tests target was higher than the iOS version of the simulator that I was trying to use.

I hope this helps someone.

cicerocamargo
  • 1,046
  • 9
  • 9