I recently worked on a project where the codebase is using storyboards in a very consistent way. Right last week, I noticed one of the storyboards triggered a couple of warnings in the XCode Issue Navigator.
They really smelled like
UILabel warnings. If not, surely like something that
had to do with text, like a
As it is always good practice to solve warnings, I clicked on one of them from the Issue Navigator and XCode opened the storyboard, focusing on a specific scene.
“Wow!…”, I exclaimed, “Like when XCode brings you to that line of code when selecting a code warning from the Issue Navigator, in the same way it brings you to the faulty scene in a storyboard when selecting one of its warning” .
So I started inspecting the scene: it was a complex one, with lots of UI components, standard as well as custom. After 10 minutes of searching I could not still find the source of my warning. Frustrated, I went on with other coding tasks I had on my plate that day. And after that working day eventually ended, I went to bed with two warnings in my head.
And so it happened that one very inspiring morning I restarted the hunt. The first thing I noticed was that when selecting a storyboard in the project navigator, XCode loaded it and focused it on the scene marked as entry point. That was for me a revelation. I am not a heavy storyboards user, so my assumption of few days before led me on a completely wrong investigation trail. At this point, back to square one, each scene was potentially the defected one. Instead of going one by one, I remembered another key aspect of XCode: the Issue Navigator is just a summary of the Report Navigator (⌘-8). If you want a tsunami of information, you only need to hit ⌘-8.
There, for every issue generated during the build phase of your project, you have the long version of the story, which by default is hidden. To read it, just click on that sort of hamburger icon at the far right of each reported event. In my case that gave me an extremely important clue: the string
Now, if you ever took the chance to peek into the XML which XCode generates to represent a storyboard, you will know that each element is identified with a unique id of the form
jsr-cw-pCf. So that was it! My faulty element was
jsr-cw-pCf. A quick search and replace in the XML led me to the UILabel that generated the warning.
So I went back to my storyboard, selected the label and the moment I opened the Attributes Inspector pane I could see the wrong setting. I unchecked the options
Automatically Adjusts Font, built the project and my warnings went back to zero.
- when opening a storyboard, the default behavior of XCode is to focus on the entry point scene
- when a build error or warning does not make sense in its short version, go to the Report Navigator to check all details.
- try to minimize all your project warnings; but this is something you already do, right?