Bug 33562 - NSInvalidArgumentException being thrown due to illegal constraint
Summary: NSInvalidArgumentException being thrown due to illegal constraint
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS Designer ()
Version: 4.0.0 (C6)
Hardware: PC Windows
: High major
Target Milestone: 4.0.0 (C6)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-09-02 04:43 UTC by Paul Johnson
Modified: 2015-09-04 07:32 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Paul Johnson 2015-09-02 04:43:14 UTC
I have a storyboard which is completely failing to load in Xcode but will in XamStudio. Unfortunately, ibtool being the evil object it is doesn't care about that and won't allow me to build out from my PC to the mac host.

I'm getting the following error

UNCAUGHT EXCEPTION (NSInvalidArgumentException): *** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: A multiplier of 0 or a nil second item together with a location for the first attribute creates an illegal constraint of a location equal to a constant. Location attributes must be specified in pairs

It looks like the problem is being caused by the following line

<constraint id="1645" firstItem="810" firstAttribute="centerX" secondItem="1363" secondAttribute="centerX" constant="0.0"/>

(I'm not 100% sure, but as the Xcode errors are somewhat vague and never actually tell you the view controller the problem is in or the ID of the controller)

On the beta branch on the PC and Mac (as of 1/9/2015)
Comment 2 Alan McGovern 2015-09-02 07:50:34 UTC
This is a tricky issue.

Basically your storyboard is corrupt and I have no idea how this kind of thing could happen. The item with id `1363` is the top level UIView in your `Payment Details` controller. Many of your constraints in many of your viewcontrollers use that item as their 'secondItem'. This means that labels/buttons/whatever in most of your view controllers are trying to align themselves against a view which *does not exist* in their hierarchy.

Do you have any idea how this could've happened? Unfortunately without steps to reproduce the problem it will be hard to figure what's going wrong. I'll take a look around anyway in case i can trigger something like this, but it's unlikely.
Comment 3 Paul Johnson 2015-09-02 08:00:32 UTC
If I remove all of the constraints from every VC, the storyboard goes straight into xcode without a problem and will also build. As to the steps to get this to happen, I had been editing the storyboard on the PC (mainly adding constraints and centering using the center icon in the designer).

I did remove the universal class setting then re-enable it, so that may have something to do with it.

Tried to build and bang.

One thing I did notice when editing the storyboard on the mac rather than the PC was a lot of the constraints going way outside of the VC.

Guess it could be just one of those random things that I manage to do which will probably never managed to get happening again. Worth reporting though just in case.
Comment 4 Alan McGovern 2015-09-02 08:36:27 UTC
Hrm... ok. I'll try play around with that and see if i can trigger an issue. Do let us know if you happen across the exact cause if we don't update the bug in the meantime
Comment 5 Alan McGovern 2015-09-04 07:32:39 UTC
I've tried a bunch of things but I'm unable to reproduce this issue with current builds of Xamarin Studio.

We had bugs in the past where the IDs were not being correctly rewritten, but those were corner cases with SizeClass mode and should not have caused this particular error. That error was that we did not always update include/exclude elements when copying/pasting things. Xcode and iOS ignored this kind of error.

So, since I can't trigger this problem and there have been at least some changes in the area of updating the IDs, i think i should probably close this until it is reproduced entirely with Xamarin Studio 5.10+ or Xamarin 4.0+ (the VS extension). The alpha of both of those has up to date code in this area.

However, if you have any more info please feel free to re-open or update the bug. This kind of problem is typically our 'high priority' style of issue, so we'll want to get it fixed as soon as we can figure it out, if it still exists in the latest builds.