Xcode woes
I tried updating this stuff after almost a year dormant, and for some reason my "schemes" were gone.
Anyways, I tried creating the schemes again, and even tried a fresh clean project, and tried the "Run in Terminal" option in Xcode:
But when I try to launch the application, it calls into Terminal, but does not seem to pass all the arguments necessary to start the program:
Last login: Tue Dec 22 21:39:16 on ttys006
/bin/bash -c 'arch -arch x86_64 '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/darwin-debug' --unix-socket=/tmp/NCUei7 --arch=x86_64 --working-dir '/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicinex/Build/Products/Debug' --disable-aslr --env='__XCODE_BUILT_PRODUCTS_DIR_PATHS=/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicinex/Build/Products/Debug' --env='MallocNanoZone=0' --env='CA_DEBUG_TRANSACTIONS=0' --env='COMMAND_MODE=unix2003' --env='__CFBundleIdentifier=com.apple.dt.Xcode' --env='NSUnbufferedIO=YES' --env='CA_ASSERT_MAIN_THREAD_TRANSACTIONS=0' --env='PWD=/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicinex/Build/Products/Debug' --env='DYLD_LIBRARY_PATH=/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicinex/Build/Products/Debug:/usr/lib/system/introspection' --env='LD_LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/../SharedFrameworks/' --env='__XPC_DYLD_LIBRARY_PATH=/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicin
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
macpro$ /bin/bash -c 'arch -arch x86_64 '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/darwin-debug' --unix-socket=/tmp/NCUei7 --arch=x86_64 --working-dir '/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicinex/Build/Products/Debug' --disable-aslr --env='__XCODE_BUILT_PRODUCTS_DIR_PATHS=/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicinex/Build/Products/Debug' --env='MallocNanoZone=0' --env='CA_DEBUG_TRANSACTIONS=0' --env='COMMAND_MODE=unix2003' --env='__CFBundleIdentifier=com.apple.dt.Xcode' --env='NSUnbufferedIO=YES' --env='CA_ASSERT_MAIN_THREAD_TRANSACTIONS=0' --env='PWD=/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicinex/Build/Products/Debug' --env='DYLD_LIBRARY_PATH=/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicinex/Build/Products/Debug:/usr/lib/system/introspection' --env='LD_LIBRARY_PATH=/Applications/Xcode.app/Contents/Developer/../SharedFrameworks/' --env='__XPC_DYLD_LIBRARY_PATH=/Users/miguel/DerivedData/TermKit-bmrjuxzzsgqpzwgkdqvtvmicin
NAME
darwin-debug -- posix spawn a process that is stopped at the entry point
for debugging.
SYNOPSIS
darwin-debug --unix-socket=<SOCKET> [--arch=<ARCH>] [--working-dir=<PATH>] [--disable-aslr] [--no-env] [--setsid] [--help] -- <PROGRAM> [<PROGRAM-ARG> <PROGRAM-ARG> ....]
DESCRIPTION
darwin-debug will exec itself into a child process <PROGRAM> that is
halted for debugging. It does this by using posix_spawn() along with
darwin specific posix_spawn flags that allows exec only (no fork), and
stop at the program entry point. Any program arguments <PROGRAM-ARG> are
passed on to the exec as the arguments for the new process. The current
environment will be passed to the new process unless the "--no-env"
option is used. A unix socket must be supplied using the
--unix-socket=<SOCKET> option so the calling program can handshake with
this process and get its process id.
EXAMPLE
darwin-debug --arch=i386 -- /bin/ls -al /tmp
In fact, the actual invocation is not triggered, I manually have to press the return key and I get the above error.
I found about this option on this StackOverflow question:
https://stackoverflow.com/questions/21998706/terminal-window-inside-xcode
While researching why this did not work, I ran into this blog post from Erica Sadun that covers this technique here:
https://ericasadun.com/2020/07/15/executing-command-line-directly-from-xcode/
And she says in a section aptly named "Xcode’s Crazy Terminal Option"
This feature is buggy as hell, produces ridiculous amounts of excess text (see this), can take a significant time to launch, and even more time for Xcode to realize the process has finished. It is impossible to use with paths that use spaces (“warning: working directory doesn't exist: '/Volumes/Kiku/Xcode/Derived'“).
While I do not have spaces on my invocation, once this state is triggered, Xcode can not stop the process, and can not even quit. You must force quit Xcode.
It does not look like a happy path to get this thing going, one alternative is probably what I recall I did last year:
- Configure somewhere "wait for launch"
- Build
- Run
- Switch to console, manually invoke
- Wait for Xcode to attach.
Which is a bit of an unpleasant experience for third parties attempting to look into this.
This might be a problem caused by using "bash", if I change my shell to zsh, it works.
Ok, it is now possible for this to work, I will document what is working later, but it seems to be fine on both my new and old machines, and one of them is using bash, and working with the attach capability.