Reputation: 4117
Unit tests cannot run on device with error
[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]
App starts normally when not running unit tests and unit tests run OK in simulator for same device type and OS (iPhone 6, iOS 10.3.3).
The full stack trace is
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x0000000180c79014 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x0000000180d43264 libsystem_pthread.dylib`pthread_kill + 112
frame #2: 0x0000000180bed9c4 libsystem_c.dylib`abort + 140
frame #3: 0x00000001806b91b0 libc++abi.dylib`abort_message + 132
frame #4: 0x00000001806d2c04 libc++abi.dylib`default_terminate_handler() + 304
frame #5: 0x00000001806e0820 libobjc.A.dylib`_objc_terminate() + 124
frame #6: 0x00000001806cf5d4 libc++abi.dylib`std::__terminate(void (*)()) + 16
frame #7: 0x00000001806cf1a8 libc++abi.dylib`__cxa_rethrow + 144
frame #8: 0x00000001806e06f8 libobjc.A.dylib`objc_exception_rethrow + 44
frame #9: 0x0000000181b5ae10 CoreFoundation`CFRunLoopRunSpecific + 532
frame #10: 0x0000000187e1afc8 UIKit`-[UIApplication _run] + 652
frame #11: 0x0000000187e15c9c UIKit`UIApplicationMain + 208
* frame #12: 0x00000001000d08d0 <AppName>`main(argc=9, argv=0x000000016fd33038) at main.m:16
frame #13: 0x0000000180b6959c libdyld.dylib`start + 4
It looks like an initialization issue when starting the unit tests. These worked before but not anymore, not sure what could be different. I have reverted to a previous revision where I am sure tests where running and I still find the same problem. It looks like something in my environment.
Things I tried that had no effect:
What could be the cause?
Upvotes: 1
Views: 797
Reputation: 4117
I haven't found the root cause but I have applied this technique to switch the AppDelegate for a dummy one to speed up unit tests, which I wanted to do anyways, and now there is no crash when running the unit tests.
Therefore it must be something in the AppDelegate that causes the app to crash only when running unit tests but not when running the app normally.
Upvotes: 1