I have a very large terminal project that relies on the ncurses library. As of the update on Dec. 11, 2024, the ncurses (and forms) API's no longer work when the app is launched from Xcode. If I run the app by double-clicking on the executable from Finder, the API's work as expected - but of course, that does not allow for debugging - which is the purpose of running within Xcode.
I have tested on a simple project that simply outputs "Hello World" and waits for the input of CR before ending. What should happen, is that "Hello Word" is output on the terminal, but instead no output occurs. I stress that everything worked prior to the update on Dec.11.
The code for main is simply this:
#include <iostream>
#include "stdlib.h"
#include "stdio.h"
#ifdef __cplusplus
#include <iostream>
#endif
#include <cassert>
#include <ncurses.h>
#include <form.h>
using namespace std;
int main(int argc, const char * argv[]) {
// cout << "Hello, World!" << endl;
// Basic test
initscr();
printw("Hello World !!!");
refresh();
int ch = 0;
while (ch != 10) {
ch = getch();
}
endwin();
return 0;
}
To link to libncurses.tbd, in Build Phases, add the libncurses.tbd from the list of Frameworks.
To output on the terminal, select the Product menu item in Xcode, then Edit Schema. Under the Options tab, change the Console selection to Terminal.
When the application runs, the terminal will launch, but no output will occur. I have Googled every topic imaginable for 2 days now but have not come up with a solution. Is there something that I need to update? It looks to me like the libraries have been updated on Dec. 11 as well, but is there something else I need to do?
For a more detailed image of one of the many screens I have working prior to this issue:
I mentioned using the Terminal option in my original post.
Sorry. I missed that.
I took another look at it anyway. I figured it out. You definitely have to use the Terminal option. But additionally, in "Edit Scheme" > Run, go to the "Info" tab. Change "Launch" to " wait for executable to be launched".
Click the "Run" button. Xcode will be in "Waiting to attach" mode.
Then, in a Terminal window, manually run the executable using a path to the debug executable in DerivedData. In my case, that was: "/Users/<me>/Library/Developer/Xcode/DerivedData/cursestest-ctczepmnawedaxejmabotxmbzwov/Build/Products/Debug/cursestest".
Make sure you have a break point already inserted where you want to start debugging. Once you run the executable manually, Xcode should detect it and automatically start debugging. It will stop at your breakpoint and you're ready to debug!