iOS Sign in button throws autolayout constraint errors

715 views
Skip to first unread message

Harshad Kale

unread,
Jun 4, 2015, 8:21:50 AM6/4/15
to google-iden...@googlegroups.com

I have been following articles over here - https://developers.google.com/identity/sign-in/ios/sign-in

I have a storyboard on which I am using a ViewController and have a view put inside of it with the class - GIDSignInButton.

The View looks right, has all the constraints to keep it in the position and works fine when I detach the GIDSignInButton class from the view.

I have exact same constraints as Google's sample signin app has. Their app also throws the same errors. In fact the error log I pasted below is from Google samples (pod try Google)

As soon as I make the view GIDSignInButton, it starts to displace. It never stays in the position where the View was.

On Xcode debug console it shows following errors -

2015-06-04 07:14:53.190 SignInExample[33750:2085778] Attempted to configure [Identity, Analytics, AdMob, SignIn, AppInvite, CloudMessaging].

2015-06-04 07:14:53.193 SignInExample[33750:2085778] Successfully configured [SignIn].

2015-06-04 07:14:53.193 SignInExample[33750:2085778] Failed to configure [].

2015-06-04 07:14:53.194 SignInExample[33750:2085778] Subspecs not present, so not configured [Identity, Analytics, AdMob, AppInvite, CloudMessaging].

2015-06-04 07:14:53.258 SignInExample[33750:2085778] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 

(

    "<NSLayoutConstraint:0x7fe1234495b0 V:[UIView:0x7fe123495a10(198)]>",

    "<NSLayoutConstraint:0x7fe123495c90 UIView:0x7fe123495a10.centerY == GIDSignInButton.centerY   (Names: GIDSignInButton:0x7fe1237a95f0 )>",

    "<NSAutoresizingMaskLayoutConstraint:0x7fe12369cd60 h=--& v=--& GIDSignInButton.midY == + 97   (Names: GIDSignInButton:0x7fe1237a95f0 )>"

)


Will attempt to recover by breaking constraint 

<NSLayoutConstraint:0x7fe123495c90 UIView:0x7fe123495a10.centerY == GIDSignInButton.centerY   (Names: GIDSignInButton:0x7fe1237a95f0 )>


Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.

The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

2015-06-04 07:14:53.259 SignInExample[33750:2085778] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 

(

    "<NSLayoutConstraint:0x7fe1236848b0 GIDSignInButton.width == 3.26531*GIDSignInButton.height   (Names: GIDSignInButton:0x7fe1237a95f0 )>",

    "<NSLayoutConstraint:0x7fe123684b00 H:[GIDSignInButton(160)]   (Names: GIDSignInButton:0x7fe1237a95f0 )>",

    "<NSAutoresizingMaskLayoutConstraint:0x7fe12369cdb0 h=--& v=--& V:[GIDSignInButton(44)]   (Names: GIDSignInButton:0x7fe1237a95f0 )>"

)


Will attempt to recover by breaking constraint 

<NSLayoutConstraint:0x7fe1236848b0 GIDSignInButton.width == 3.26531*GIDSignInButton.height   (Names: GIDSignInButton:0x7fe1237a95f0 )>


Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.

The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

Akash Gupta

unread,
Jun 8, 2015, 6:10:47 AM6/8/15
to google-iden...@googlegroups.com
I have been facing a similar issue. The GIDSignInButton in my case has been placed on the storyboard itself, with autolayout constraints applied to it. It is causing a layout error message similar to Harshad's and is getting desplaced when in the rendered view.

Akash Gupta

unread,
Jun 8, 2015, 8:04:35 AM6/8/15
to google-iden...@googlegroups.com
I have been able to fix the issue by placing the button as a subview of another UIView to which I applied the required autolayout constraints.

Derek Salama

unread,
Jun 9, 2015, 5:21:25 PM6/9/15
to google-iden...@googlegroups.com, gupta....@gmail.com
This isn't quite the right forum for you (see developers.google.com/identity/toolkit).

For assistance with Google Sign In, please post your question on Stack Overflow with the google-signin tag.

Harshad Kale

unread,
Jun 9, 2015, 11:44:44 PM6/9/15
to google-iden...@googlegroups.com
Awesome. I never thought of doing that, Cool, it worked. Thanks man.

Jorge Luis Canizales Diaz

unread,
Jun 10, 2015, 7:54:55 PM6/10/15
to google-iden...@googlegroups.com
Thanks for your solution Akash!

Peter Andrews

unread,
Jun 18, 2015, 2:34:20 PM6/18/15
to google-iden...@googlegroups.com
Thanks for the feedback here.  In the next few weeks we will be releasing a new version of Google Sign-In for iOS that addresses this and a few other issues.
Reply all
Reply to author
Forward
0 new messages