toolsVersion="11201" is messing my storyboard - ios

After updating my xCode to 8.0 and run my application on my device, i've noticed that my collection view in the storyboard is messed and the frame isn't fitting the view anymore.
This is happening only if i opened the storyboard(It seems that the xcode is adding some properties after the first time I opened the file in xcode).
When I replace the storyboard with my old one then build the app without opening it everything worked as expected.
After hours of searching what may be the reason and comparing the storyboards source codes (between the old one and the new one after opening it), I have found that the reason is the toolsVersion property found at the top of the storyboard source code.
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0"
toolsVersion="11201" systemVersion="15G1004" targetRuntime="iOS.CocoaTouch"
propertyAccessControl="none" useAutolayout="YES" colorMatched="YES"
initialViewController="wZn-Em-z41">
When I replace toolsVersion="11201" with toolsVersion="10116" then everything works again normally.
How can I force the tools version to a value? and what is this property and why it is messing up my constraints and frames.
Appreciate any information about this issue.

The problem here is that, with toolsVersion 11201 (Xcode 8), it seems that views that have fully qualified constraints no longer have frames specified in the storyboard (since the constraints will determine the frame at runtime).
So you can't rely on the frame until the constraints have been evaluated (i.e. don't use frames in viewDidLoad or viewWillAppear). Once the constraints have been evaluated, the frame seems to be fine. Before they have been evaluated, the frame seems to be reported as 1000 x 1000 (at least, that's what it was for me in various cases).
So there are two solutions: 1) Make an outlet to your constraints and use that instead of relying on the frame, or 2) use the frame after the constraints have been evaluated (for example, in the viewDidAppear method).

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!

iOS designer not rendering storyboard

In the Xamarin.IOS editor I get this error:
"There was a problem parsing the XML in this document"
System.NullReferenceException: Object reference not set to an instance of an object
at MonoTouch.Design.ProxiedView.set_UseSafeArea (System.Boolean value) [0x00001] in /Users/vsts/agent/2.154.3/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Shared/ProxiedView.cs:944
at MonoTouch.Design.ProxiedViewController.UpdateLayoutGuides (MonoTouch.Design.Catalog utilityCatalog, MonoTouch.Design.IosDocument rootModel) [0x002ac] in /Users/vsts/agent/2.154.3/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Shared/ProxiedViewController.cs:238
at MonoTouch.Design.Storyboard.UpdateLayoutGuides (MonoTouch.Design.Catalog utilityCatalog) [0x00017] in /Users/vsts/agent/2.154.3/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Shared/Storyboard.cs:132
at MonoTouch.Design.Client.IPhoneDesignerSession.LoadXml (System.Func`1[TResult] getDoc, System.Boolean shouldTryUpgrade, System.String fileName) [0x00310] in /Users/vsts/agent/2.154.3/work/1/s/Xamarin.Designer.iOS/MonoTouch.Design.Client/IPhoneDesignerSession.cs:466
I tried disabling things and retracing every step I made doing the storyboard, the only thing that half worked was disabling autolayout, but it destroyed my layout.
The thing is that it works perfect in the app and xcode but in the VS iOS designer it doesn't work, and I need it to add the ids of the components to use them my ViewController, in my project it's the only way to add ids.
I´m lost, if you need any extra info ask me, I pasted the important (or so I think) part of the logs, they were too long.
This is the iPad version of a storyboard that works perfectly, it was based of that storyboard (copied and pasted then edited to fit with iPad)
This is the storyboard: https://pastebin.com/QAHEBne0
The problem with your file was that somehow you have constraints related with the safeArea but it was not turn on in the file.
I fix it when I open the file in my Xcode and just turn in on(check the image)
the result is useSafeAreas="YES" added to document tag on the second row in your xml
Please, check your constraints carefully it is possible some of them to be broken or deleted.

Xcode auto layout issue when open app

i set all constraints there is no probmem. But when i re-open the project all widths and heights values changes to 1000. There is only one view has problem. I deleted it then created again but still has same problem. How can i solve this?
Apparently this is a bug in Xcode 8.
Related Question: xcode-8-storyboard-warnings-for-navigation-bar-width
A possible solution presented in that related question is to change the Simulated Metrics size from Fixed to Freeform.
Also, here some open threads about common problems:
https://forums.developer.apple.com/thread/62929
https://forums.developer.apple.com/thread/63108
https://forums.developer.apple.com/thread/63144
https://forums.developer.apple.com/thread/61797
https://forums.developer.apple.com/thread/63029
https://forums.developer.apple.com/thread/63068
https://forums.developer.apple.com/thread/63067
https://forums.developer.apple.com/thread/63067
https://forums.developer.apple.com/thread/62821
https://forums.developer.apple.com/thread/62882
https://forums.developer.apple.com/thread/62321

Xcode crash on opening storyboard

I am developing an app for iOS with Xamarin. Lately, I haven't been able to access my storyboard file in Xcode or compile my app anymore because Xcode crashes right away when opening the .storyboard file.
The error message is the following:
ASSERTION FAILURE <br>
Details: Creating an out of band arbitration unit with a view (<IBUITableViewCell: 0x7fa88d13a5d0>) as the root under another view (<IBUITableView: 0x7fa88cf000e0>) is not yet implemented.<br>The view would need to be in two arbitration units, the one above for positioning constraints, and the root of the one below for sizing constraints. <br>But then that means that subviews cannot have constraints that affect the size of the view, so the view must have ibExternalTranslatesAutoresizingMaskIntoConstraints set to YES.
<br>Object: <IBUITableViewCell: 0x7fa88d13a5d0>
<br>Method: -ibArbitrationUnitWasCreatedWithReceiverAsRootUnderParent:
I tried rebasing my storyboard to the last version that worked (the one the app was submitted to the app store) and weirdly, even that version didn't work.
My plan was to manually remove and every view controller and add them one by one to figure out where the error is.
However I don't understand why XCode crashes when opening the storyboard and not just shows me exactly where the error in my xml is.
So if anyone has encountered this problem before and has a better way to fix it than to manually do it, I would really appreciate any help.
ibExternalTranslatesAutoresizingMaskIntoConstraints needs to be YES
Sounds like the Storyboard was created with an older Xamarin.iOS that introduce this issue.
The fastest solution is to open the storyboard in vi (or Xcode / View As Source, or another text editor of your choice, and replace all translatesAutoresizingMaskIntoConstraints="NO" with "".
Save the file, re-open it in the Storyboard editor and fix your contraints.

Xcode Image Catalogs: Image not showing in Interface Builder

So, the artist sent me a Resources.xcassets folder that I simply dragged into the project. I then jumped to interface builder, added a new UIImageView, assigned an image name from the xcassets, and to my surprise, I couldn't see the images. It shows as a blue question mark.
Notice, that the IB autocomplete is working, and when I run the application, the assets actually show up! But not in interface builder, which makes laying the assets around virtually impossible, especially with the size to fit not working...
Bug reported: 15733387
It seems I am at fault... I created a fresh new XIB, and made sure to select device family 'iPad', and the image is now showing up properly. I didn't think that was the problem because you cannot change the device family after creating the XIB! I looked everywhere for that options, but never found it... Seeing the raw XIB files, you can do this change manually, I guess (Notice where it says ".iPad"):
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="12F45" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="4514" systemVersion="12F45" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none">
Yeah, I actually solved it, and the problem is super crazy. The artist had set all the assets as "iPad" assets, so the Contents.json file inside the *.imageset folder was assigning the "ipad" to the images I have. I opened the json file in sublime text, and changed the "ipad" to "universal", and BOOM. I had Xcode open on the side, and the image showed up almost instantly in IB!! Like, wth...

Resources