简体   繁体   中英

iOS, Swift: “Unable to simultaneously satisfy constraints” in syslog

My first iOS app got rejected by the App Review team because it crashed on launch. I can't reproduce this crash. The app runs fine on my physical iPad Mini and on all the Xcode simulators. Also, the same build and archive was passed through TestFlight Internal Testing. I have so far not been able to symbolicate the crash logs they sent me. However, I did find this in the syslog:

Aug  7 17:04:44 Michaels-MacBook-Pro-3 SpringBoard[1333]: Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x7fccfccd0300 UILabel:0x7fccfccc8510' '.leading == SPUISearchTableHeaderView:0x7fccfccc59f0.leadingMargin>",
    "<NSLayoutConstraint:0x7fccfccd0f80 H:[UILabel:0x7fccfccc8510' ']-(NSSpace(8))-[UIButton:0x7fccfcccb710'Show More']>",
    "<NSLayoutConstraint:0x7fccfccd0fd0 SPUISearchTableHeaderView:0x7fccfccc59f0.trailingMargin == UIButton:0x7fccfcccb710'Show More'.trailing>",
    "<NSLayoutConstraint:0x7fccfccc8880 'UIView-Encapsulated-Layout-Width' H:[SPUISearchTableHeaderView:0x7fccfccc59f0(0)]>"
)

Looking at this, it seems to pertain to a table view, a label and a button. My app is based on the standard Master-Detail project. So there is only one table view in it, the master, and there is only one label in that view, which is in the prototype cell. At one point, I experimented with a disclosure button in the prototype cell, and I suspect the Show More on the second to the last line above may be a lingering effect from that.

Searching on SPUISearchTableHeaderView I found this in github. I notice that it does add a couple of constraints. And those constraints actually contain the text moreButton .

So I feel like I may be on the trail of the cause of the crash: I'm thinking it's some constraints being added programmatically, possibly left over from my experiment with the disclosure button. But I'm not at all sure how to proceed from here. There are no explicit constraints on the label (see screen shot below), and I don't think there ever were. Any help will be greatly appreciated! 屏幕截图显示标签

Based on Konstantin's suggestion below, I tried to add constraints to the label, but the only ones available are horizontal and vertical centering. Others are grayed out. (See screenshot below.) And when I try to select horizontal centering, the Add Constraints button at the bottom remains grayed out, so I can't add it!

在此处输入图片说明

That's because you have width = 0.

UIView-Encapsulated-Layout-Width' H:[SPUISearchTableHeaderView:0x7fccfccc59f0(0)]

It may happen when you miss some constrains for Label, which is left from Show More Button

H:[UILabel:0x7fccfccc8510' ']-(NSSpace(8))-[UIButton:0x7fccfcccb710'Show More']>

Verify that these label has leading constraints.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM