Xcode 16.2 ncurses no longer works

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:

Answered by Etresoft in 821622022

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!

The Xcode debugger console is a very funky environment. I'm more surprised that it was working before than that it isn't working now.

There is a way to get closer.

In Xcode, go to Edit Scheme... Click the Options tab Scroll to the bottom and change Console to "Terminal"

This will launch your app in a real Terminal window. You can debug in Xcode and see the output in a separate Terminal window, at least in theory.

I tried it with your code and I couldn't get it to work. It works, but it doesn't display any output. Perhaps you can hack around on environment variables or something? Or perhaps there are other ncurses functions or settings you can try that will make it work. And there might be some way to dig into the "darwin-debug" executable that is running your executable.

Your observations are correct. I mentioned using the Terminal option in my original post. But thanks for trying.

Accepted Answer

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!

Thanks so much. The solution you have provided indeed allows for debugging. I will mark the answer as accepted, but I would still like to know why Xcode no longer allows for debugging as it did prior to the last update. At least this allows me to continue my work!

I would still like to know why Xcode no longer allows for debugging as it did prior to the last update.

I don't know exactly. I know that Apple made major changes to the Console in Xcode 15.

It doesn't surprise me at all that ncurses wouldn't work in the Console. I'm surprised it was working before.

Xcode 16.2 ncurses no longer works
 
 
Q