xcode will not run code in debugger properly.

I'm am on a MacBook Pro (Retina, 13-inch, Early 2015) with 2.7 GHz Intel Core i5 and 8 GB 1867 MHz DDR3. I am running Xcode Version 8.3 (8E162). Also, I am a student learning C++ using Xcode.


When running the following code:


#include <iostream>

usingnamespacestd;

int main()

{

cout << "Hello";

}


It will not display Hello or any cout command for that matter. I have tried uninstalling and reinstalling Xcode. I have tried taking it in and out of Developer mode with the Terminal Command DevToolsSecurity -disable (or --enable) And that will not resolve the issue.

This started a week ago when I had to install some package that would not let me use the program unless I installed the update for the debugger. Any ideas would be greatly appreciated.

MacBook Pro with Retina display, macOS Sierra (10.12.4)

Posted on Apr 4, 2017 8:14 PM

Reply
9 replies

Apr 4, 2017 9:27 PM in response to ben70345

Oh I see, I was under the impression that your build was failing and no errors were showing. My bad! So it's your output console. I'm guessing you're not getting what I have here. Normally, I would try using another IDE, like Netbeans, but that wouldn't exactly answer your question. If nothing shows up in the output window, my best guess would be a build failed, but obviously there's no errors with the code. Maybe, the output window is hidden or squished because it's a small window or something? Or someone changed your font colour of the output to white? 😝User uploaded file

Apr 4, 2017 8:29 PM in response to ben70345

It's kind of hard to know what the problem is because you haven't listed any errors that show in your code (you should always include them when asking for troubleshooting in the future). I'm going to guess that the "Build Failed" due to trouble accessing the C++ library that allows for commands like cout.


Try creating new Command Line Tool project in Xcode. Make sure that the language selected is C++ in the next window.

Apr 4, 2017 8:32 PM in response to Acefirefly

There are no errors. Xcode will simply not show anything in the debugger. As stated in the original post, "It will not display Hello or any cout command for that matter."

Xcode is somehow preventing the debugger from displaying code. I went to the Apple Store and they had no idea. They tested it on their local machine and it gave them the same response.

Apr 4, 2017 8:48 PM in response to ben70345

Try checking to make sure that the debugger is enabled to show errors:


Click Xcode on the top menu bar, preferences. Under General, ensure "Show live issues" is check marked. Under General, ensure "Notify using bezel or system notification" is enabled for the Build: Succeeds and Build: Fails. Then completely quit out of Xcode to save changes (right click the icon in dock and quit).

Apr 4, 2017 9:03 PM in response to Acefirefly

This is not an error with the Code. The code in the original post may potentially be the simplest code one can write for C++ it is just an example. The code could be


#include <iostream>

using namespace std;



void reverse_array(float array2[], int size)

{

float array3[size];

for (int k=(size-1); k>=0; k--)

array3[size-k-1] = array2[k];

for (int i=0; i<size; i++)

array2[i]=array3[i];

}


int main()

{

int size=10;

float array[10];

cout << "**Please enter 10 numbers. Your 10 numbers and the reverse order of your 10 numbers will be printed below**" << endl;

for (int i=0; i<10; i++)

{

cout << "Please enter number:";

cin >> array[i];

}


for (int j=0; j<10; j++)

{

cout << array[j]<< "; ";

}

cout << endl;

reverse_array(array, size);

for (int j=0; j<10; j++)

{

cout << array[j]<< "; ";

}


cout << endl;

return 0;

}


To reverse an array and it will still not print out anything. If you use an online C++ shell, all of the codes listed will run just fine without any errors. The issue is with Xcode. These codes have all run null of errors until the update a week ago. Now, nothing with print out onto the screen. It will only accept values.

Apr 5, 2017 6:24 PM in response to ben70345

I'm having this same problem as well. It started after I updated Xcode to version 8.3. If you add a newline or '<< endl' to 'cout << "Hello World!";' it will print. For some reason previous versions were flushing the output buffer without a newline or endl but this latest version is not. It took me a while and a bit of frustration to figure it out. I guess someone toggled something in the default settings and I don't know where to look. I've taken to writing my C++ code in a text editor and compiling and running it from the command line. LOL. Aren't IDEs great?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

xcode will not run code in debugger properly.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.