How To Debug And Get Error Messages In Xcode Step By Step

After you create a swift project in Xcode and write some swift source code, you must want to debug your iOS app to help you to find out and fix errors exist in your app. Debug and find error messages in Xcode is very easy, this article will tell you how to do it.

1. How To Set BreakPoint In Xcode.

  1. Open your Xcode project, then edit your swift source code file ViewController.swift by click it.
  2. If you want to add a breakpoint, just click the beginning of the source code line. When you see there is a blue arrow at the beginning of the swift source code line, this means the breakpoint has been added.
  3. You can right click the breakpoint to popup a breakpoint manager menu list, you can do a lot of operations ( such as edit, disable, delete and reveal ) to this breakpoint by these menu items.
    xcode break point popup menu list
  4. When you click the Edit Breakpoint… menu item, it will popup another dialog which will let you to set breakpoint condition ( the breakpoint take effect only when this condition is matched ) or add breakpoint action ( the action can be a shell command etc. ).
    xcode edit breakpoint popup dialog
  5. When you click the Disable Breakpoint menu item, the breakpoint will be disabled, and the source code execution will not stop at the breakpoint, and the breakpoint arrow’s color change to light blue also.
  6. When you click the Delete Breakpoint menu item, the breakpoint will be removed.

2. How To Start Debug Source Code In Xcode.

Just click the triangle Build and then run the current schema button at xcode top left ( xcode run debug stop ios program button ) to start the iOS app as normal, when the code execution run to the breakpoint, it will stop there, and then you can debug the swift source code such as watch variable values etc.

READ :   How To Add iOS App Icon, Image, Color Set To Xcode Project Assets Catalog Correctly

3. How To Find Out iOS App Execution Error Messages In Xcode.

If you find your iOS app do not act as what you want, maybe there are some exceptions that has been thrown. But you should get the exception message to analyze the error reason. You can find the error messages follow below steps.

  1. Click View —> Debug Area —> Activate Console menu item to show the activate console window at the bottom right of Xcode editor debug area. All the log, warning and error message text will be printed in this console window.
    xcode - view - debug area - activate console
  2. If you can not see the activate console window, you can click the View —> Debug Area —> Show Debug Area sub menu item in above menu list to display the Debug Area first, then click View —> Debug Area —> Activate Console menu item to display the active console at debug area right side.
  3. find error message in xcode view debug area activate console

References

  1. How To Create A Swift Project In Xcode

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.