2

I'm attempting to test my app. I'm using the UITest settings that were created for my by Xcode when the project was first created. The app uses CoreText and attributed strings heavily.

2015-09-02 14:11:05.958 my_app[66864:11465921] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITextView _baselineOffsetFromBottom] only valid when using auto layout'
*** First throw call stack:
(
    0   CoreFoundation                      0x007da214 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x02531e42 objc_exception_throw + 50
    2   CoreFoundation                      0x007da0aa +[NSException raise:format:arguments:] + 138
    3   Foundation                          0x00e1aad2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 118
    4   UIKit                               0x01bdffff -[UITextView _baselineOffsetFromBottom] + 209
    5   UIKit                               0x01b09579 -[UIView(UIConstraintBasedLayout) _alignmentDebuggingOverlayCreateIfNecessary:] + 608
    6   UIKit                               0x0127d22d -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1080
    7   libobjc.A.dylib                     0x025460f9 -[NSObject performSelector:withObject:] + 70
    8   QuartzCore                          0x0382c134 -[CALayer layoutSublayers] + 148
    9   QuartzCore                          0x0381ff28 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
    10  QuartzCore                          0x0381fd8c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    11  QuartzCore                          0x03812c6b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
    12  QuartzCore                          0x0384643b _ZN2CA11Transaction6commitEv + 589
    13  QuartzCore                          0x03846cee _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    14  CoreFoundation                      0x006f464e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    15  CoreFoundation                      0x006f45ae __CFRunLoopDoObservers + 398
    16  CoreFoundation                      0x006e9758 CFRunLoopRunSpecific + 504
    17  CoreFoundation                      0x006e954b CFRunLoopRunInMode + 123
    18  UIKit                               0x011b81af -[UIApplication _run] + 540
    19  UIKit                               0x011bd38f UIApplicationMain + 160
    20  my_app                             0x000680bc main + 140
    21  libdyld.dylib                       0x03feda21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

My unit test is completely vanilla.

import XCTest

class my_appUITests: XCTestCase {

    override func setUp() {
        super.setUp()

        // Put setup code here. This method is called before the invocation of each test method in the class.

        // In UI tests it is usually best to stop immediately when a failure occurs.
        continueAfterFailure = false
        // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
        XCUIApplication().launch()
    }

    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }

    func testExample() {
        // Use recording to get started writing UI tests.
        // Use XCTAssert and related functions to verify your tests produce the correct results.
    }

}

I'm using Xcode 7 Beta 4, is this a bug in that particular build? Or am I missing something about UITests and autolayout?

  • Upgrading seems to have gotten me past this error, but left me with a completely new one. I hope this is because Xcode7 is still in beta, not just because they're leaving UITests in this state. –  Sep 02 '15 at 15:29
  • 1
    It looks like the crash is occurring in the app, not the UI Tests. The actual exception being raised states: `-[UITextView _baselineOffsetFromBottom] only valid when using auto layout` – Joe Masilotti Sep 09 '15 at 14:02
  • I understand. However I can't reproduce that crash in anywhere but the UITests. This doesn't happen if I just build and run the app. So something in the UITests must be triggering the crash. –  Sep 15 '15 at 10:48

0 Answers0