4

I upgraded to XCode 8, and I am going through hell of being able to run my tests sometimes... For example, I just was testing some code, and was able to run my tests 3 times in a row... and then the 4th time I got:

dyld: could not load inserted library 'PLATFORMS/iPhoneOS.platform/Developer/Library/PrivateFrameworks/IDEBundleInjection.framework/IDEBundleInjection' because image not found

*** If you believe this error represents a bug, please attach the log file at /Users/patrick/Library/Developer/Xcode/DerivedData/MyApp-hjfppqmgxqrprucknvwtakynpqxs/Logs/Test/2B6C2EAE-5C13-40C9-BACE-3A00AA74F3EF/Session-UnitTests-2016-09-20_124123-gk3pW0.log

I have rebooted my iOS device, rebooted my computer, deleted derrived data, etc... It will no longer run tests. ARRRGH!!!!

UPDATE

I should mention, I am trying to run tests on my iPad, I can't run tests on the simulator because I have too much code having to do with NEON intrinsics, and so the simulator wont run.

But what does seem to work is, when this happens, switch to build tests on my iPhone, then it when it builds, it just says "running tests" and the spinner spins forever, but no tests are actually running... I can actually tap on my app and interact with it, which is usually not the behavior I get when running tests... Anyway I then stopped the build, switched back to my iPad and now tests run again.

patrick
  • 9,290
  • 13
  • 61
  • 112
  • Possible duplicate of http://stackoverflow.com/questions/32405833/xcode-7-0-xctest-dyld-could-not-load-inserted-library-idebundleinjection – matt Sep 20 '16 at 19:58

2 Answers2

2

I get this error consistently with XCode 8.0 running on my iPad (Version 10.0.2 (14A456)) when I run test code that causes an uncaught exception in the code under test. There may be other examples, but it happens any time the code under test fails catastrophically.

When the unit test fails with an exception, XCode does not recover properly.

I believe this is a problem with XCode; this answer provides a workaround. The unit test will fail at the exception, and subsequent runs produce the 'image not found' error.

The simplest recovery I've found is the following:

  • Set device target to Generic iOS Device
  • Disconnect my iPad
  • Reboot the iPad
  • Connect everything back together

Here is an example failure that demonstrates the problem;

Notice that the core issue in this example is that I have written a bad unit test; I'm passing a nil parameter to a method that is subsequently used to try adding a nil object to a dictionary.

Update: for the sake of accuracy, the issue was that I was passing an immutable dictionary as a parameter when a mutable one was expected, thus producing the 'unrecognized selector' error. In any case, the exception is what causes XCode to behave badly.

  Assertions: failed: caught "NSInvalidArgumentException", "-[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance 0x1818f200"
(
    0   CoreFoundation                      0x1dd89e1f <redacted> + 154
    1   libobjc.A.dylib                     0x1cfef077 objc_exception_throw + 38
    2   CoreFoundation                      0x1dd8f515 <redacted> + 0
    3   CoreFoundation                      0x1dd8d589 <redacted> + 700
    4   CoreFoundation                      0x1dcb2f08 _CF_forwarding_prep_0 + 24
    5   tDefense                            0x000cd299 +[PlayingPiece addPlayingPiece:atLocation:onBoard:] + 326
    6   tDefense                            0x000cd5ad +[PlayingPiece addNewPiece:atLocation:onBoard:] + 154
    7   tDefenseTests                       0x00410777 -[PlayFieldTests testGetNeighbors] + 4594
    8   CoreFoundation                      0x1dd8e864 <redacted> + 68
    9   CoreFoundation                      0x1dcaf349 <redacted> + 294
    10  XCTest                              0x00307de5 __24-[XCTestCase invokeTest]_block_invoke_2 + 472
    11  XCTest                              0x0033b0dd -[XCTestContext performInScope:] + 312
    12  XCTest                              0x00307c07 -[XCTestCase invokeTest] + 296
    13  XCTest                              0x00308439 -[XCTestCase performTest:] + 560
    14  XCTest                              0x0030578d -[XCTestSuite performTest:] + 520
    15  XCTest                              0x0030578d -[XCTestSuite performTest:] + 520
    16  XCTest                              0x0030578d -[XCTestSuite performTest:] + 520
    17  XCTest                              0x002f1d55 __25-[XCTestDriver _runSuite]_block_invoke + 52
    18  XCTest                              0x00312325 -[XCTestObservationCenter _observeTestExecutionForBlock:] + 628
    19  XCTest                              0x002f1bed -[XCTestDriver _runSuite] + 512
    20  XCTest                              0x002f29b7 -[XCTestDriver _checkForTestManager] + 300
    21  XCTest                              0x0033c55b _XCTestMain + 690
    22  CoreFoundation                      0x1dd45bc3 <redacted> + 10
    23  CoreFoundation                      0x1dd455a7 <redacted> + 230
    24  CoreFoundation                      0x1dd43a61 <redacted> + 752
    25  CoreFoundation                      0x1dc93073 CFRunLoopRunSpecific + 486
    26  CoreFoundation                      0x1dc92e81 CFRunLoopRunInMode + 104
    27  GraphicsServices                    0x1f43bbfd GSEventRunModal + 156
    28  UIKit                               0x22e34acf <redacted> + 574
    29  UIKit                               0x22e2f201 UIApplicationMain + 150
    30  tDefense                            0x000d690f main + 106
    31  libdyld.dylib                       0x1d45e50b <redacted> + 2
)
  File: <unknown>
Curt Eckhart
  • 455
  • 5
  • 11
1

I was having exactly the same problem after upgrading to Xcode 8 / Swift 2.3. One of deleting derived data, rebooting the phone and closing and re-opening Xcode just fixed it.

Robert Atkins
  • 23,528
  • 15
  • 68
  • 97