Error Treatment Techniques Hit in iOS App Development ~ Xcode Edition ~

Error treatment

An error that always hits when developing an application. I can't find a solution by searching. Development will be delayed and motivation will be discouraged. I think that is something that everyone experiences. I myself am one of them, and every day I am keenly aware of the lack of technical skills. In this article, I would like to introduce a few techniques for efficiently clarifying errors and achieving overwhelming growth when developing with Xcode.

Who is the target of this article

--For those who have just started developing iOS apps (in Xcode) ――What is LLDB? What is a debugger? Those who say --The added UI parts (button, viwe ...) are not displayed! Where did you go Those who say

Treatment 1 ~ LLDB ~

LLDB is Xcode's default debugger. It's at the bottom of the screen you're all familiar with. A debugger is a function or software that helps you find the cause of a problem. Basically, you can find the error by pausing the program.

Above is the familiar Xcode screen. The bottom part of the screen is the debugger. Here, a breakpoint is set on the 14th line to pause the program. You can set a breakpoint by clicking the line number. You can unlock it by grabbing a breakpoint and dragging it onto the code. On the right screen of the debugger

(lldb)

You can find the cause of the error by entering the command in the part where is written.

po command

This is the command you will probably use the most. po outputs variables. For example, when a breakpoint is set on the 19th line as shown below. スクリーンショット 2020-12-23 20.38.44.png

po lemon

You can check the value of the variable at that time by typing. This example doesn't make sense, but I think it will be useful someday.

Treatment 2 ~ Where are the UI parts? ?? ~

The button that should have been added disappears when the simulation is started. .. Where did you go Is there a code mistake? What an experience I think. This is often an unexpectedly simple mistake. However, before you get used to it, it tends to take time to clarify the cause. (I feel that time will lead to growth, but it's better than nothing.) Here's one way to deal with this problem.

Hidden features of Xcode ~ View Debugger ~

The view debugger is a function that allows you to check the current view hierarchy in 3D. While running the simulator スクリーンショット 2020-12-23 20.42.45.png You can check it by clicking here. スクリーンショット 2020-12-23 20.45.10.png Like this. In this example, I don't feel much benefit from the view debugger, but I think that the larger the app, the more opportunities to use it. By using this function, you can check where the added UI part is, whether it is hidden under other UI parts, and so on. There are quite a few things that say, "Thanks to the view debugger, I was able to find and rescue the UI parts that were lost!"

in conclusion

"What should I write about the Advent calendar?" The theme was not decided until the last minute and the posting was delayed. Personally, it was painful, so I wondered if I could run away without writing an article. At first, I started writing with a sense of duty, but it made me feel better and I feel that my worries have become a little easier. I realized that regular output is important. (Thanks to Qiita and Pasona Tech!)

This time, I wrote what I wanted to know when I started developing iOS apps. I am still a beginner, so please point out any mistakes. Thank you. I will update the contents as I grow up. And I hope this article helps those who have troubles.

[](In the process of writing an article, organizing and investigating information gave me an opportunity to make new discoveries and reconsider myself. Thank you to Pasona Tech for giving me the opportunity to write!)

Recommended Posts

Error Treatment Techniques Hit in iOS App Development ~ Xcode Edition ~
iOS app development: Timer app (summary)
Complete self-study IOS app development diary
iOS App Development Skill Roadmap (Introduction)
iOS app development: Timer app (4. Countdown implementation)
iOS app development: Timer app (1. Timer time setting)
iOS app development: Timer app (10. Create animation)
Trial and error to display national holidays in Android app development. Part 2