Hey! I've been using Quick and Nimble for a while now, and it's been going really great! That is until I upgraded to Xcode 7.3 (7D175) today. Also upgraded Quick to 0.9.1 and Nimble to 3.2.0, in order to get it to build.
When I run my unit tests (don't have UI tests), I get a crash nearly immediately after launch. I do get some logs from my own app though, so it's not _actually_ before startup, but before any tests get run. I get some weird logs, and then I print out the backtrace:
17:40:09.959 MyApp[11149:5773890] _XCT_testBundleReadyWithProtocolVersion:minimumVersion: reply received
17:40:09.980 MyApp[11149:5773945] _IDE_startExecutingTestPlanWithProtocolVersion:16
(lldb) bt
* thread #1: tid = 0x5819ec, 0x000000010e96b04b libobjc.A.dylib`realizeClass(objc_class*) + 1114, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x1084c5f10)
frame #0: 0x000000010e96b04b libobjc.A.dylib`realizeClass(objc_class*) + 1114
frame #1: 0x000000010e96b5d9 libobjc.A.dylib`realizeAllClasses() + 81
frame #2: 0x000000010e96d152 libobjc.A.dylib`objc_copyClassList + 37
frame #3: 0x000000011c885172 XCTest`+[XCTestCase(RuntimeUtilities) allSubclasses] + 53
frame #4: 0x000000011c84d0ed XCTest`+[XCTestSuite _suiteForBundleCache] + 175
frame #5: 0x000000011c84e450 XCTest`-[XCTestSuite _initWithTestConfiguration:] + 1227
frame #6: 0x000000011c84e674 XCTest`+[XCTestSuite testSuiteForTestConfiguration:] + 50
frame #7: 0x000000011c83a979 XCTest`-[XCTestDriver _runSuite] + 233
frame #8: 0x000000011c83b7d1 XCTest`-[XCTestDriver _checkForTestManager] + 259
frame #9: 0x000000011c885a9a XCTest`_XCTestMain + 628
frame #10: 0x000000010e09a2ec CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
frame #11: 0x000000010e08ff75 CoreFoundation`__CFRunLoopDoBlocks + 341
frame #12: 0x000000010e08f6d2 CoreFoundation`__CFRunLoopRun + 850
frame #13: 0x000000010e08f0f8 CoreFoundation`CFRunLoopRunSpecific + 488
frame #14: 0x000000010fd13ad2 GraphicsServices`GSEventRunModal + 161
frame #15: 0x000000010be37f09 UIKit`UIApplicationMain + 171
* frame #16: 0x0000000107f03342 MyApp`main + 114 at AppDelegate.swift:19
frame #17: 0x000000010f46392d libdyld.dylib`start + 1
Before this, I get a lot of those "Class X is implemented in both in Y and Z. One of the two will be used. Which one is undefined." messages. May or may not be related.
I tried making a sample project to isolate the problem, but the most basic of basic sample applications didn't have the problem, so it could be a problem with my configuration?
Hey @cjwirth, this looks like it could be a tough one to track down.
Could you try adding a new empty unit test bundle to your project that uses the same test host, and check to see if this crash occurs when trying to load that? And/or try removing the Quick framework and all files which reference Quick from the existing test bundle. I'd like to better understand whether this error is related Quick itself, or whether the crash also happens with just XCTest being loaded.
Thanks for the response. Yeah, I don't really know how to track track this one down.
I added a new unit test bundle that is testing my main app, although does not import Quick or Nimble. It still builds them (because it builds the Pods project for the other test bundles). I only have 1 test which is just XCTAssert(false, "Just to see if it passes through here")
:confused:
Same problem -- except this time I don't get the "Class X is implemented..." errors.
Looks like you're probably right in that it's not a problem with Quick or Nimble...
Hey! Sorry, it's been a while. I found my problem!
It turns out the first stored property on a Class has to be something visible from Objective-C, otherwise it crashes when loading the class. it wasn't crashing when I ran the app because I never got to the part where it loads the class that crashes -- but my tests did!
Wrote a little bit about it here: https://cjwirth.com/tech/xcode-7-3-crashing
@cjwirth Thank you so much for the write up. In 6 years of iOS development that might be the most ridiculous bug and solution combo I've ever seen.
I had the same error in a test class. Basically I was defining the class I was testing above the interface of the test class. If you omit the implementation file this causes the crash.
Most helpful comment
Hey! Sorry, it's been a while. I found my problem!
It turns out the first stored property on a Class has to be something visible from Objective-C, otherwise it crashes when loading the class. it wasn't crashing when I ran the app because I never got to the part where it loads the class that crashes -- but my tests did!
Wrote a little bit about it here: https://cjwirth.com/tech/xcode-7-3-crashing