Tag Archives: LLDB

Best practices for software development with Swift

via schwa/Swift-Community-Best-Practices · GitHub.

This document grew from an set of notes I produced while working on SwiftGraphics. Most of the recommendations in this guide are definitely considered opinions and arguments could be made for other approaches. That’s fine. When other approaches make sense they should be presented in addition.

These best practices do not dictate or recommend whether Swift should be used in an procedural, object-oriented or functional manner. Instead a pragmatic approach is taken. Individual recommendations might be focused on object-oriented or functional solutions as needed.

The scope of this document is mostly aimed at the Swift language and Swift standard library. That said specific recommendations on how to use Swift with Mac OS, iOS, WatchOS and TVOS might be provided if a unique Swift angle or insight can be provided. Hints & tips style recommendations on how to use Swift effectively with Xcode and LLDB might also be provided.

This is very much a work in progress. Contributions are very much appreciated in the form of pull requests or filing of issues.

Discussion can be found on the Swift-Lang slack (in the #bestpractices channel)

LLDB Expression for Code Injection in Xcode

via LLDB Debugging | Advanced Xcode Tutorial.

LLDB (http://lldb.llvm.org), described on the official webpage as a next generation, high-performance debugger, is the debugger that’s currently shipped with Xcode. Just a few years ago, LLDB replaced gdb, and now LLDB is the only debugger supported by Xcode. In this app developer tutorial, I will show you how to use the LLDB debugger and the expression command when developing iOS and watchOS apps.

You can run LLDB from the Terminal typing: xcrun lldb. The xcrun command points the Terminal to the LLDB version shipped with Xcode (the Xcode bundle contains tons of tools). If you omit the xcruncommand, the Terminal executes LLDB installed in the /usr/bin/ directory, which could contain a different version than the LLDB used by Xcode.

Unfortunately, executing LLDB from the Terminal app is only useful to debug apps that are not sandboxed. If you want to debug an iOS or watchOS app, you need to use LLDB from the Xcode console when executing the app with the Apple IDE. After compiling and running an app, you can access the LLDB console at any time by pressing the Pause button in the Xcode UI (see next figure).