Copy result from LLDB to clipboard
Did you need to copy the result of po command to clipboard? Well, I needed, and it was a JSON of 1000+ lines. It was so painful to select everything from the LLDB console.
Thankfully, there's an option to create a custom LLDB command using Swift!
expr -l Swift -O -- will tell LLDB to interpret everything after -- as Swift code.
First, we need to create a custom LLDB command that can be used from the debug session.
To create custom command execute following in LLDB console
Doing it this way will make this command available for the current running LLDB session. As soon as the session is terminated, command won't be available.
To make the command available for all LLDB sessions, we need to add it to ~/.lldbinit file. To create LLDB copy command, execute the following in terminal.
If we try to run a copy command in LLDB session that is already running, it will show the following error.

We can re-run application from Xcode. Or, we can reload it by executing following from LLDB console.
copy command will use String representation from what is passed.
Copying value from UserDefaults
Copy object description
And we will have the following text in our clipboard
Autocomplete is not working with custom LLDB commands. Simple workaround is to use po and then change it with copy.