Autolayout issues not printed in console output - ios

I'm setting up layout from code. For some reason autolayout issues (conflicting constraints, missing constraint) are not printed at all to console output.
Statements printed using print() function are printed correctly.
Any idea how to fix this problem? Setting up layout from code is really problematic without this output.
Version of Xcode: 9.3.1

Missing constraints are never printed to the console. Only conflicting constraints are. I have no idea why you're not seeing those, if you have conflicting constraints. But in any case you can check your constraints in a much better way: run the app, get into the situation you want to check, and then switch to Xcode and choose Debug > View Debugging > Capture View Hierarchy. If there are layout issues, they will be clearly called out.

Related

Xcode 13 iOS 15 Programmatic Obj-C Constraints translatesAutoresizingMaskIntoConstraints

I use 100% programmatic constraints in my interface code. Upgraded to Xcode 13 and iOS 15. Got tons of NEW execution warnings about constraints, all saying that the system had to break some constraints to comply with others. I had not seen such warnings for several years, and have not touched my constraint code in all that time. Yet thorough testing shows my code continues to run correctly. What's up?
Answer: I had been a bit cavalier with the timing of when iOS actually calculated the constrained dimensions. I put all of my programmatic interface declarations into a single method. At the bottom of that method, I have long had code that went beyond interface layout, into NavCon preliminaries. Among those NavCon declarations, I had lines like:
self.view_D0_Tutorial.frame = self.view_CenterPane_D0_Tutorial.frame;
I noted at the time that I wrote and debugged those lines, that using the debugger to ask what the location data was, all I ever got was CRect (0,0,0,0), yet the code somehow did the right thing.
Well, in the upgrade, iOS apparently changed the way they do things. I had to do two things in response.
(1) moved all the NavCon preliminary code to a new separate method, and call it with performSelector and 0 delay.
(2) changed the simple frame assignment to a more limited assignment:
self.view_D0_Tutorial.frame = CGRectMake(0, 0, self.view_CenterPane_D0_Tutorial.frame.size.width, self.view_CenterPane_D0_Tutorial.frame.size.height);;
The combination made the error messages go away, and my code continues to run correctly!

App crashes with [ServicesDaemonManager] interruptionHandler is called. -[FontServicesDaemonManager connection]_block_invoke

My App crashes randomly with this error:
[ServicesDaemonManager] interruptionHandler is called.
-[FontServicesDaemonManager connection]_block_invoke
(didReceiveMemoryWarning fires before the error message)
It is a bit hard to post code because of the randomness.
I use SwiftUI (UIHostingController), #ObserverObjects, async network calls, transitions to other views, etc.
It all works fine most of the time but sometimes i ran into this error.
The memory is then increasing constantly until the app crashes.
I tried to fix all possible memory leaks (to deallocate all images, [weak self], ...)
didn't help.
I'am not sure what the FontServicesDaemonManager is doing and in what way it is involved but all fonts are using the system font:
.font(Font.system(size: 25 , weight: .regular))
Sometimes also this error appears right after the one from obove:
-[UIWindow endDisablingInterfaceAutorotationAnimated:] called on <UIWindow: 0x10aab11a0; frame = (0 0; 375 812); gestureRecognizers = <NSArray: 0x10acb2510>; layer = <UIWindowLayer: 0x10aacbee0>> without matching -beginDisablingInterfaceAutorotation. Ignoring.
Anyone ran into similar issues or has an idea how to fix this?
(Xcode 11.6)
Update:
This problem is usually related to Autolayout constraints. Please check your constraints of all related views.
Hope you got the answer, I am here describing my scenario:
I got the same error with Xcode 11.6, the issue was I had enabled the zoombie object on scheme & it was creating [ServicesDaemonManager] interruptionHandler. So please check it. Reason behind memory warning was loading of high resolution images on mail thread which was not good. Adding download image in background thread worked for me.
Thanks,
Ratneshwar
This problem is usually related to constraints, there must be some ambiguity with your constraints, that's why you are getting this error.
Had the same issue with one of my collection views, because the constraints were not properly set for smaller screens. Check the constraints again and you will be good to go.
The problem i had was related to Autolayout and some constraints that did work for fullscreen for a specific view. I changed the Autolayout constraints and since then i had no crashes related to this issue anymore..

Autolayout yellow warnings. Will it crash my app in run time

In storyboard , I am seeing a lot of yellow warning. Upon clicking the yellow warning , I get like update frame or update constraints. In the console it throws auto-layout warnings too. I just want to know whether it will crash my app because of this.enter image description here
Yellow warnings and auto-layout warnings in console are not related.
Yellow warnings means that what you see in IB is not what you will get at runtime according to current constraints. If you want to see what you will get you should click yellow warning and press "update frame". If you want to get at runtime what you currently see in IB you should press yellow warning and select "update constraint".
Runtime warnings in console means some constraints conflict at runtime. You should analyse the warning message to find what is the issue.
Most of the time it will not. But I suggest you to fix them all.
why not update all the frames, the difference Xcode complains about is not much, and NO it wont crash your application, BUT Xcode complains as there might be situations where your constraints wont work as per you set them.
Your Application will not crash weather it is a Yellow one or a Red one .
Xcode only means that the constrains you have kept may not work properly in different modes and resolutions .
You can simply fix it by simply clicking on update constraints,but result may not be what you expected.
So click on yellow arrow and read suggestion by xcode.

Unit Tests crash with estimatedItemSize on Collection View Flow Layout - EXC_ARITHMETIC

I have a UICollectionViewFlowLayout with an estimatedItemSize set.
When I run my application, everything works fine, but in my unit tests, I get an EXC_ARITHMETIC crash every time I hit collectionView:dequeueReusableCellWithReuseIdentifier:.
I know this is due to my estimatedItemSize as removing it fixes the crash.
Does anyone have any idea why this is happening?
Thanks
I have the same problem with UICollectionViewFlowLayout and estimatedItemSize. I filed a radar and Apple closed it as a duplicate with no further suggestions as a workaround. My best guess and research thus far indicates that self-sizing cells are fundamentally broken on iOS 8 / 9.
Try random values of estimatedItemSize. For me, setting sizes that closely match the resulting size of your cells cause a crash but sizes much smaller than your cells (1,1) for example do not crash.
I know this is not what you want to hear but it might be the only option until Apple fixes UICollectionView.

Why doesn't Interface Builder objects shows up on screen?

I've never had any problem with Interface Builder elements before (labels, sliders, switches etc), but suddenly I can't get new ones to show up in the app!
I can drag them in to the view, arrange them as I want, set values etc, but when I run the code they are gone.
A mysterious thing is that I can set values to them in the code without problem, like:
self.myNewLabel.text = #"test"
And if I stop the code with a breakpoint and ask the console
po self.myNewLabel.text it gives me "test"
But still, nothing shows up on the screen!
I've searched for any hidden or alpha properties that was set by misstake, but found nothing.
What are the pitfalls here? What am I missing?
System Info:
Xcode 6.1
OSX 10.10
Running on iOS 8.0 device
Check the constraints created by Interface Builder - they may be inadvertently pushing your UI elements off-screen.

Resources